summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-19 14:18:41 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-19 14:18:41 +0000
commit5999efa3acaaa27764e5899a4329ecc50d4b4c7f (patch)
tree46665914432e2fc25473337830041ea0e8f35303 /src
parent3572d8887273ebad19e37df9b044807146e9869b (diff)
downloadiconv-5999efa3acaaa27764e5899a4329ecc50d4b4c7f.tar.gz
iconv-5999efa3acaaa27764e5899a4329ecc50d4b4c7f.tar.bz2
Fix up output buffer length on memory exhaustion
svn path=/trunk/iconv/; revision=5733
Diffstat (limited to 'src')
-rw-r--r--src/iconv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/iconv.c b/src/iconv.c
index 80d4caa..8e26c67 100644
--- a/src/iconv.c
+++ b/src/iconv.c
@@ -441,8 +441,12 @@ int character_callback(void *handle, UCS4 c)
* documentation says that the buffer pointer AND free
* space count are left unmodified if nothing is written.
* Therefore, we have this hack until UnicodeLib gets fixed.
+ *
+ * We need to restore the space remaining in the output buffer
+ * on memory exhaustion, too. Otherwise, it will be negative,
+ * which will break the client.
*/
- if (ret == -1) {
+ if (ret <= 0) {
*e->outbytesleft = prev_outbytesleft -
(*e->outbuf - prev_outbuf);
}