convert: fixed recent change

This commit is contained in:
Дмитрий Левин 2002-06-13 14:39:30 +00:00
parent 105656feba
commit c0574eb4aa

View File

@ -1435,14 +1435,17 @@ convert (char *ed, const char *td, const char *lang)
((icd = iconv_open (to_codeset, from_codeset)) != (iconv_t) - 1)) ((icd = iconv_open (to_codeset, from_codeset)) != (iconv_t) - 1))
{ {
size_t insize = strlen (ed); size_t insize = strlen (ed);
size_t inbufleft = insize, outbufleft = insize * 4; size_t inbufleft = insize, outbufleft = insize * 4 + 1;
char buf[outbufleft]; char buf[outbufleft];
char *inbuf = ed, *outbuf = buf; char *inbuf = ed, *outbuf = buf;
if (iconv (icd, &inbuf, &inbufleft, &outbuf, &outbufleft) > 0 if (iconv (icd, &inbuf, &inbufleft, &outbuf, &outbufleft) >= 0)
&& strcmp (ed, buf)) {
/* XXX memory leak */ *outbuf = '\0';
result = strdup (buf); if (strcmp (ed, buf))
/* XXX memory leak */
result = strdup (buf);
}
iconv_close (icd); iconv_close (icd);
} }