bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

another striconv fix


From: Bruno Haible
Subject: another striconv fix
Date: Sun, 21 Jan 2007 23:17:30 +0100 (MET)
User-agent: KMail/1.5.4

This fixes an errno value in case of an out-of-memory failure.

2007-01-21  Bruno Haible  <address@hidden>

        * lib/striconv.c (str_iconv): Guarantee errno is set when strdup fails.
        * lib/striconveh.c (str_iconveh): Likewise.

*** lib/striconv.c      16 Jan 2007 03:25:12 -0000      1.7
--- lib/striconv.c      21 Jan 2007 22:10:57 -0000
***************
*** 386,392 ****
  str_iconv (const char *src, const char *from_codeset, const char *to_codeset)
  {
    if (c_strcasecmp (from_codeset, to_codeset) == 0)
!     return strdup (src);
    else
      {
  #if HAVE_ICONV
--- 386,398 ----
  str_iconv (const char *src, const char *from_codeset, const char *to_codeset)
  {
    if (c_strcasecmp (from_codeset, to_codeset) == 0)
!     {
!       char *result = strdup (src);
! 
!       if (result == NULL)
!       errno = ENOMEM;
!       return result;
!     }
    else
      {
  #if HAVE_ICONV
*** lib/striconveh.c    21 Jan 2007 22:04:33 -0000      1.3
--- lib/striconveh.c    21 Jan 2007 22:10:57 -0000
***************
*** 920,926 ****
             enum iconv_ilseq_handler handler)
  {
    if (c_strcasecmp (from_codeset, to_codeset) == 0)
!     return strdup (src);
    else
      {
  #if HAVE_ICONV
--- 920,932 ----
             enum iconv_ilseq_handler handler)
  {
    if (c_strcasecmp (from_codeset, to_codeset) == 0)
!     {
!       char *result = strdup (src);
! 
!       if (result == NULL)
!       errno = ENOMEM;
!       return result;
!     }
    else
      {
  #if HAVE_ICONV





reply via email to

[Prev in Thread] Current Thread [Next in Thread]