This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH to libiberty/argv.c


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]