Don't do SILC_STRING_LANGUAGE conversion with NULL pointers since
authorPekka Riikonen <priikone@silcnet.org>
Sun, 23 Jun 2002 14:29:38 +0000 (14:29 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 23 Jun 2002 14:29:38 +0000 (14:29 +0000)
on some platforms it's not allowed.

CHANGES
lib/silcutil/silcstrutil.c

diff --git a/CHANGES b/CHANGES
index 01fbdc4a4168fea133365bcaec9c0853298022e5..b2f1792419ad4c337f9df1d932f26b96a9ba842e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+Sun Jun 23 17:32:31 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Added silc_client_udpate_server function to update changed
index 0e2398ae1467585f1c7293a6e790d51c0a25d2bb..904873062130a79133c2350b31410e2fce571c96 100644 (file)
@@ -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