From: Frédéric Marchal Date: Mon, 11 Jan 2010 08:37:08 +0000 (+0000) Subject: Possible fix for bug #1841109: report an error if iconv fails to convert the string X-Git-Tag: v2_2_7~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=077095486efde6d1a7f2ad3beca8282d7788f54b;p=thirdparty%2Fsarg.git Possible fix for bug #1841109: report an error if iconv fails to convert the string --- diff --git a/grepday.c b/grepday.c index d5d8bde..736cb21 100644 --- a/grepday.c +++ b/grepday.c @@ -64,8 +64,17 @@ static char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontl sstr = (char *) sstring; localtoutf = iconv_open ("UTF-8", CharSet); - iconv (localtoutf, (ICONV_CONST char **)&str, &slen, &sstr, &sslen); - iconv_close (localtoutf); + if (localtoutf==(iconv_t)-1) { + fprintf(stderr,"SARG(grepday) iconv cannot convert from %s to UTF-8 - %s\n",CharSet,strerror(errno)); + strcpy(sstring,string); //show something sensible on the graph + } + else { + if (iconv (localtoutf, (ICONV_CONST char **)&str, &slen, &sstr, &sslen)==-1) { + fprintf(stderr,"SARG(grepday) iconv failed to convert string \"%s\" from %s to UTF-8 - %s\n",string,CharSet,strerror(errno)); + strcpy(sstring,string); //show something sensible on the graph + } + iconv_close (localtoutf); + } retval = gdImageStringFTEx (im, brect, fg, fontlist, ptsize, angle, x, y, sstring, gdFTEX_Unicode); free(sstring);