X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=blobdiff_plain;f=src%2Fcodeconv.c;h=f4c662593e8626a97351e061cb82cbfdb7556ad2;hp=fa1bb18b1d112aacfb90fcecfda5cb2210e3505e;hb=5201ffa9b8e6548f7a5e541042499fe1a023ebff;hpb=2950d3231d1849881f3ed557797404d1c2c83f8e diff --git a/src/codeconv.c b/src/codeconv.c index fa1bb18b1..f4c662593 100644 --- a/src/codeconv.c +++ b/src/codeconv.c @@ -820,12 +820,12 @@ gchar *conv_iconv_strdup(const gchar *inbuf, while ((n_conv = iconv(cd, (ICONV_CONST gchar **)&inbuf_p, &in_left, &outbuf_p, &out_left)) < 0) { if (EILSEQ == errno) { - g_free(outbuf); - outbuf = NULL; - break; + inbuf_p++; + in_left--; + *outbuf_p++ = SUBST_CHAR; + out_left--; } else if (EINVAL == errno) { - g_free(outbuf); - outbuf = NULL; + *outbuf_p = '\0'; break; } else if (E2BIG == errno) { out_size *= 2; @@ -842,10 +842,8 @@ gchar *conv_iconv_strdup(const gchar *inbuf, } } - if (outbuf) { - iconv(cd, NULL, NULL, &outbuf_p, &out_left); - outbuf = g_realloc(outbuf, strlen(outbuf) + 1); - } + iconv(cd, NULL, NULL, &outbuf_p, &out_left); + outbuf = g_realloc(outbuf, strlen(outbuf) + 1); iconv_close(cd);