summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/iconvme.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/iconvme.c b/lib/iconvme.c
index aa12d24adc..e920e3d461 100644
--- a/lib/iconvme.c
+++ b/lib/iconvme.c
@@ -253,7 +253,16 @@ again2:
}
# endif
- *outp = '\0';
+ *outp++ = '\0';
+
+ /* Give away unused memory. */
+ if (outp - dest < outbuf_size)
+ {
+ char *newdest = (char *) realloc (dest, outp - dest);
+
+ if (newdest != NULL)
+ dest = newdest;
+ }
out:
if (have_error)