This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to libiberty/argv.c
- From: ja2morri at csclub dot uwaterloo dot ca (James A. Morrison)
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: gcc-patches at gcc dot gnu dot org, DJ Delorie <dj at redhat dot com>,Ian Lance Taylor <ian at airs dot com>
- Date: 13 Apr 2005 07:46:40 -0400
- Subject: Re: PATCH to libiberty/argv.c
- References: <m31x9fdsfq.fsf@uniton.integrable-solutions.net>
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> Hi,
>
> I found this bug while feeding libiberty to g++, which choked on the
> invalid (in C++) conversion of void* -> T*
>
> copy[argc] = malloc (sizeof (char *) * (len + 1));
>
> Mechanically, I casted the result to (char **), only to discover that
> it was invalid too. Further inspection of the code effectively
> releaved that the variable copy is of type "char **" and the function
> is trying to copy a string at the slot copy[argc] which is of type
> char *. Consequently, we should be allocating (len + 1) bytes,
> not sizeof (char *) * (len + 1).
>
> OK to apply?
>
> -- Gaby
>
> 2005-04-13 Gabriel Dos Reis <gdr@integrable-solutions.net>
>
> * argv.c (dupargv): Mallocate space of argv[argc], not
> sizeof(char *) of that amuont. Cast result to char *.
Mallocate? Also s/amuont/amount/g.
--
Thanks,
Jim
http://www.student.cs.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim