From 5999efa3acaaa27764e5899a4329ecc50d4b4c7f Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 19 Nov 2008 14:18:41 +0000 Subject: Fix up output buffer length on memory exhaustion svn path=/trunk/iconv/; revision=5733 --- src/iconv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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); } -- cgit v1.2.3