diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2013-01-06 22:34:18 +0000 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2013-01-06 22:34:18 +0000 |
commit | efe52d57b2e0d1cb15ce3ccea5dd7d5e0359dae4 (patch) | |
tree | 1c772e308c8f35530c52bd889ee897d71a500814 /src/iconv.c | |
parent | 097de4ee4cd1e7df6661c94b87a5389e0cf50b77 (diff) | |
download | iconv-efe52d57b2e0d1cb15ce3ccea5dd7d5e0359dae4.tar.gz iconv-efe52d57b2e0d1cb15ce3ccea5dd7d5e0359dae4.tar.bz2 |
Correct handling of trailing valid shift sequences. Previously would
erroneously report EINVAL, instead of silently accepting them.
Requires UnicodeLib 0.60.
Diffstat (limited to 'src/iconv.c')
-rw-r--r-- | src/iconv.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/iconv.c b/src/iconv.c index 45bd15f..db47cbc 100644 --- a/src/iconv.c +++ b/src/iconv.c @@ -356,12 +356,19 @@ size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, /* Clear current write state */ e->write_state = WRITE_NONE; - if (e->in) + if (e->in) { read = encoding_read(e->in, character_callback, *inbuf, *inbytesleft, e); - else + + /* A trailing complete nullable sequence should + * result in success */ + if (e->write_state == WRITE_NONE && + !encoding_read_in_multibyte_sequence(e->in)) + e->write_state = WRITE_SUCCESS; + } else { read = iconv_eightbit_read(e, character_callback, *inbuf, *inbytesleft, e); + } /* Stop on error */ if (e->write_state != WRITE_SUCCESS) |