Blob Blame History Raw
diff --git a/src/iri.c b/src/iri.c
index 9b16639..da9dc7f 100644
--- a/src/iri.c
+++ b/src/iri.c
@@ -183,17 +183,12 @@ do_conversion (iconv_t cd, char *in, size_t inlen, char **out)
         }
       else if (errno == E2BIG) /* Output buffer full */
         {
-          char *new;
-
           tooshort++;
           done = len;
-          outlen = done + inlen * 2;
-          new = xmalloc (outlen + 1);
-          memcpy (new, s, done);
-          xfree (s);
-          s = new;
-          len = outlen;
-          *out = s + done;
+          len = done + inlen * 2;
+          s = xrealloc (s, len + 1);
+          *out = s + done - outlen;
+          outlen += inlen * 2;
         }
       else /* Weird, we got an unspecified error */
         {