summary refs log tree commit diff
path: root/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'iconv')
-rw-r--r--iconv/gconv.c2
-rw-r--r--iconv/iconv.c9
2 files changed, 7 insertions, 4 deletions
diff --git a/iconv/gconv.c b/iconv/gconv.c
index 6e3080b0e9..b9c404ac03 100644
--- a/iconv/gconv.c
+++ b/iconv/gconv.c
@@ -39,7 +39,7 @@ __gconv (__gconv_t cd, const unsigned char **inbuf,
   assert (converted != NULL);
   *converted = 0;
 
-  cd->__data[last_step].__outbuf = *outbuf;
+  cd->__data[last_step].__outbuf = outbuf != NULL ? *outbuf : NULL;
   cd->__data[last_step].__outbufend = outbufend;
 
   if (inbuf == NULL || *inbuf == NULL)
diff --git a/iconv/iconv.c b/iconv/iconv.c
index ee16d3b091..c1b96164e5 100644
--- a/iconv/iconv.c
+++ b/iconv/iconv.c
@@ -39,9 +39,12 @@ iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
 
   if (inbuf == NULL || *inbuf == NULL)
     {
-      result = __gconv (gcd, NULL, NULL, (unsigned char **) outbuf,
-			(unsigned char *) (outstart + *outbytesleft),
-			&converted);
+      if (outbuf == NULL || *outbuf == NULL)
+	result = __gconv (gcd, NULL, NULL, NULL, NULL, &converted);
+      else
+	result = __gconv (gcd, NULL, NULL, (unsigned char **) outbuf,
+			  (unsigned char *) (outstart + *outbytesleft),
+			  &converted);
     }
   else
     {