Mercurial > hg > octave-lojdl > gnulib-hg
changeset 7917:0b6b5a675452
Ensure errno when strdup fails.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 21 Jan 2007 22:18:23 +0000 |
parents | d431200a045d |
children | 2b63866dabc7 |
files | ChangeLog lib/striconv.c lib/striconveh.c |
diffstat | 3 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-01-21 Bruno Haible <bruno@clisp.org> + + * lib/striconv.c (str_iconv): Guarantee errno is set when strdup fails. + * lib/striconveh.c (str_iconveh): Likewise. + 2007-01-21 Bruno Haible <bruno@clisp.org> * lib/striconveh.h (mem_iconveh): New declaration.
--- a/lib/striconv.c +++ b/lib/striconv.c @@ -398,7 +398,13 @@ str_iconv (const char *src, const char *from_codeset, const char *to_codeset) { if (c_strcasecmp (from_codeset, to_codeset) == 0) - return strdup (src); + { + char *result = strdup (src); + + if (result == NULL) + errno = ENOMEM; + return result; + } else { #if HAVE_ICONV