From 769ca58867a6b1e25a6b7558c17175fdfa579709 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 5 Sep 2006 11:47:33 +0000 Subject: [PATCH] (iconv_alloc): Don't assume that malloc() or realloc(), when failing, sets errno to ENOMEM. (malloc on GNU/kFreeBSD doesn't.) --- lib/iconvme.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; } -- 2.39.5