bug-gnulib
[Top][All Lists]
Advanced

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

[bug-gnulib] Re: iconv made easy


From: Paul Eggert
Subject: [bug-gnulib] Re: iconv made easy
Date: Sun, 26 Dec 2004 21:48:15 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> +         if (newsize <= outbuf_size
> +             || !(newdest = realloc (dest, newsize)))
> +           {
> +             have_error = 1;
> +             goto out;
> +           }

If newsize <= outbuf_size, this sets have_error=1 and the remaining
code eventually uses errno.  But errno is garbage at that point.  You
need to set errno to ENOMEM in that case.

> +    if (iconv_close (cd) < 0)
> +      have_error = 1;
> +    else
> +      errno = save_errno;
> +
> +    if (have_error && dest)
> +      {
> +     free (dest);
> +     dest = NULL;
> +     errno = save_errno;
> +      }

Again, the resulting errno is incorrect if iconv_close returns a
negative number and dest is nonzero.

It might not hurt for you to review all the paths to the code that
uses errno, to make sure that it can't be garbage.


> I'm not sure about the cast of 'str' to 'ICONV_CONST char *'.  Is
> iconv guaranteed to not modify the input string content?

I think so, but I think on some hosts the prototype is char * for
historical reasons.




reply via email to

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