On OSF/1 (and possibly other platforms whose malloc(0) can be NULL), the mem_cd_iconveh function could return a NULL string rather than a "freshly allocated memory block".
It showed up as a unit test failure on OSF/1. 2008-03-30 Bruno Haible <[EMAIL PROTECTED]> Avoid failure when attempting to return empty iconv results on some platforms. * lib/striconveh.c (mem_cd_iconveh_internal): In the final memory allocation, don't report ENOMEM when the resulting string is empty. *** lib/striconveh.c.orig 2008-03-30 18:38:20.000000000 +0200 --- lib/striconveh.c 2008-03-30 18:37:46.000000000 +0200 *************** *** 1,5 **** /* Character set conversion with error handling. ! Copyright (C) 2001-2007 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software: you can redistribute it and/or modify --- 1,5 ---- /* Character set conversion with error handling. ! Copyright (C) 2001-2008 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software: you can redistribute it and/or modify *************** *** 870,878 **** /* Now the final memory allocation. */ if (result == tmpbuf) { char *memory; ! memory = (char *) malloc (length + extra_alloc); if (memory != NULL) { memcpy (memory, tmpbuf, length); --- 870,879 ---- /* Now the final memory allocation. */ if (result == tmpbuf) { + size_t memsize = length + extra_alloc; char *memory; ! memory = (char *) malloc (memsize > 0 ? memsize : 1); if (memory != NULL) { memcpy (memory, tmpbuf, length); *************** *** 887,895 **** else if (result != *resultp && length + extra_alloc < allocated) { /* Shrink the allocated memory if possible. */ char *memory; ! memory = (char *) realloc (result, length + extra_alloc); if (memory != NULL) result = memory; } --- 888,897 ---- else if (result != *resultp && length + extra_alloc < allocated) { /* Shrink the allocated memory if possible. */ + size_t memsize = length + extra_alloc; char *memory; ! memory = (char *) realloc (result, memsize > 0 ? memsize : 1); if (memory != NULL) result = memory; }