summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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);
}