]> Savannah Git Hosting - gnulib.git/commitdiff
(iconv_alloc): Don't assume that malloc() or realloc(), when failing, sets
authorBruno Haible <bruno@clisp.org>
Tue, 5 Sep 2006 11:47:33 +0000 (11:47 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 5 Sep 2006 11:47:33 +0000 (11:47 +0000)
errno to ENOMEM. (malloc on GNU/kFreeBSD doesn't.)

lib/iconvme.c

index 0e3d7b5ccd7954da72fa0faa8f53a30a030ef45d..5de84cc5298d2fc023391582ff6a420fbd2a4c54 100644 (file)
@@ -131,7 +131,10 @@ iconv_alloc (iconv_t cd, const char *str)
 
   outp = dest = (char *) malloc (outbuf_size);
   if (dest == NULL)
-    return NULL;
+    {
+      errno = ENOMEM;
+      return NULL;
+    }
 
 again:
   err = iconv (cd, &p, &inbytes_remaining, &outp, &outbytes_remaining);
@@ -159,6 +162,7 @@ again:
            newdest = (char *) realloc (dest, newsize);
            if (newdest == NULL)
              {
+               errno = ENOMEM;
                have_error = 1;
                goto out;
              }