From 15ac4c23912dae187b9887c960321e76b27d75b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim Rühsen?= Date: Tue, 4 Nov 2014 12:48:25 +0100 Subject: [PATCH] * iri.c (remote_to_utf8): fix crash on do_conversion() failure --- src/ChangeLog | 5 +++++ src/iri.c | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 5ad7605..dbf7d9b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-11-04 Tim Ruehsen + + * iri.c (do_conversion): fix quote() misuse + * iri.c (remote_to_utf8): fix segfault on do_conversion() error + 2014-11-03 Jakub Čajka * iri.c (remote_to_utf8): Fixed assumption that char is signed. Fixes diff --git a/src/iri.c b/src/iri.c index 11f2bda..dd2806d 100644 --- a/src/iri.c +++ b/src/iri.c @@ -123,8 +123,9 @@ do_conversion (const char *tocode, const char *fromcode, char *in, size_t inlen, cd = iconv_open (tocode, fromcode); if (cd == (iconv_t)(-1)) { - logprintf (LOG_VERBOSE, _("Conversion from %s to %s isn't supported\n"), - quote (opt.locale), quote ("UTF-8")); + logprintf (LOG_VERBOSE, _("Conversion from %s to UTF-8 isn't supported\n"), + quote (opt.locale)); + *out = NULL; return false; } @@ -146,7 +147,7 @@ do_conversion (const char *tocode, const char *fromcode, char *in, size_t inlen, *(s + len - outlen - done) = '\0'; xfree(in_save); iconv_close(cd); - logprintf (LOG_VERBOSE, _("converted '%s' (%s) -> '%s' (%s)\n"), in_org, fromcode, *out, tocode); + DEBUGP (("converted '%s' (%s) -> '%s' (%s)\n", in_org, fromcode, *out, tocode)); return true; } @@ -187,7 +188,7 @@ do_conversion (const char *tocode, const char *fromcode, char *in, size_t inlen, xfree(in_save); iconv_close(cd); - logprintf (LOG_VERBOSE, _("converted '%s' (%s) -> '%s' (%s)\n"), in_org, fromcode, *out, tocode); + DEBUGP (("converted '%s' (%s) -> '%s' (%s)\n", in_org, fromcode, *out, tocode)); return false; } @@ -291,7 +292,7 @@ remote_to_utf8 (struct iri *iri, const char *str, const char **new) ret = true; /* Test if something was converted */ - if (!strcmp (str, *new)) + if (*new && !strcmp (str, *new)) { xfree ((char *) *new); return false; -- 2.1.1