diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2014-05-19 19:12:27 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2014-05-19 19:12:27 +0000 |
commit | 0474c596b6fc5152a8dd28b518db0e33e4a3a632 (patch) | |
tree | 800e28c63ee3879c824dc725a69cd63fd3678e93 | |
parent | 9f23ea79805f561f2f9fbd2e46cfd5c9914076e8 (diff) |
Fixed segOutputSize < segSize assertion fails at htscharset.c:993
* closes:#44
-rw-r--r-- | src/htscharset.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/htscharset.c b/src/htscharset.c index 0184382..4137d65 100644 --- a/src/htscharset.c +++ b/src/htscharset.c @@ -966,24 +966,29 @@ char *hts_convertStringUTF8ToIDNA(const char *s, size_t size) { if (HTS_IS_LEADING_UTF8(c)) { /* commit sequence ? */ if (utfSeq != (size_t) -1) { - /* unicode character */ - punycode_uint uc = 0; /* Reader: can read bytes up to j */ #define RD ( utfSeq < j ? segData[utfSeq++] : -1 ) /* Writer: upon error, return FFFD (replacement character) */ -#define WR(C) uc = C != -1 ? (punycode_uint) C : (punycode_uint) 0xfffd +#define WR(C) do { \ + if ((C) != -1) { \ + /* copy character */ \ + assertf(segOutputSize < segSize); \ + segInt[segOutputSize++] = (C); \ + } \ + /* In case of error, abort. */ \ + else { \ + FREE_BUFFER(); \ + return NULL; \ + } \ +} while(0) - /* Read Unicode character. */ + /* Read/Write Unicode character. */ READ_UNICODE(RD, WR); #undef RD #undef WR - /* copy character */ - assertf(segOutputSize < segSize); - segInt[segOutputSize++] = uc; - /* not anymore in sequence */ utfSeq = (size_t) -1; } |