summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2006-09-05 11:47:33 +0000
committerBruno Haible <bruno@clisp.org>2006-09-05 11:47:33 +0000
commit769ca58867a6b1e25a6b7558c17175fdfa579709 (patch)
treec80351022a2fa350c0f3421f7068ba6c6138c2ae
parentd50444df2498a9c9b165ed0497ea66485024a3cb (diff)
downloadgnulib-769ca58867a6b1e25a6b7558c17175fdfa579709.tar.gz
(iconv_alloc): Don't assume that malloc() or realloc(), when failing, sets
errno to ENOMEM. (malloc on GNU/kFreeBSD doesn't.)
-rw-r--r--lib/iconvme.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/iconvme.c b/lib/iconvme.c
index 0e3d7b5ccd..5de84cc529 100644
--- a/lib/iconvme.c
+++ b/lib/iconvme.c
@@ -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;
}