From: Pekka Riikonen Date: Sun, 23 Jun 2002 14:29:38 +0000 (+0000) Subject: Don't do SILC_STRING_LANGUAGE conversion with NULL pointers since X-Git-Tag: silc.client.0.9.4~6 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=3e87ea3385b034a15180b12cf6d020608f61dd79 Don't do SILC_STRING_LANGUAGE conversion with NULL pointers since on some platforms it's not allowed. --- diff --git a/CHANGES b/CHANGES index 01fbdc4a..b2f17924 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +Sun Jun 23 17:32:31 EEST 2002 Pekka Riikonen + + * Don't do SILC_STRING_LANGUAGE encoding if the outbuffer + is NULL since seems that on some platforms NULL is allowed + and on some it's not. Fallback encoding is used instead. + Affected file lib/silcutil/silcstrutil.c. + Sat Jun 22 21:34:59 EEST 2002 Pekka Riikonen * Added silc_client_udpate_server function to update changed diff --git a/lib/silcutil/silcstrutil.c b/lib/silcutil/silcstrutil.c index 0e2398ae..90487306 100644 --- a/lib/silcutil/silcstrutil.c +++ b/lib/silcutil/silcstrutil.c @@ -206,14 +206,13 @@ SilcUInt32 silc_utf8_encode(const unsigned char *bin, SilcUInt32 bin_len, ocp = (char *)utf8; inlen = bin_len; outlen = utf8_size; - if (icd != (iconv_t)-1 && - (iconv(icd, &icp, &inlen, &ocp, &outlen) != -1)) { - utf8_size -= outlen; - iconv_close(icd); - return utf8_size; - } else { - if (icd != (iconv_t)-1) + if (icp && ocp && icd != (iconv_t)-1) { + if (iconv(icd, &icp, &inlen, &ocp, &outlen) != -1) { + utf8_size -= outlen; iconv_close(icd); + return utf8_size; + } + iconv_close(icd); } } #endif @@ -350,14 +349,13 @@ SilcUInt32 silc_utf8_decode(const unsigned char *utf8, SilcUInt32 utf8_len, ocp = (char *)bin; inlen = utf8_len; outlen = bin_size; - if (icd != (iconv_t)-1 && - (iconv(icd, &icp, &inlen, &ocp, &outlen) != -1)) { - bin_size -= outlen; - iconv_close(icd); - return bin_size; - } else { - if (icd != (iconv_t)-1) + if (icp && ocp && icd != (iconv_t)-1) { + if (iconv(icd, &icp, &inlen, &ocp, &outlen) != -1) { + bin_size -= outlen; iconv_close(icd); + return bin_size; + } + iconv_close(icd); } } #endif