[NeilB@earthling.net: Re: Possible bug in tradcpp.c?]

Neil Booth NeilB@earthling.net
Mon Nov 6 10:59:00 GMT 2000


----- Forwarded message from Neil Booth <NeilB@earthling.net> -----

Subject: Re: Possible bug in tradcpp.c?
From: Neil Booth <NeilB@earthling.net>
To: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
Cc: zack@wolery.stanford.edu, gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org
Date: Mon, 6 Nov 2000 18:55:57 +0000

Kaveh R. Ghazi wrote:-

>  > 	strcpy (buf, "\"\"");
>  > 
>  >       break;
>  >     }
> 
> I think that last strcpy will try to copy two double quotes into a
> NULL pointer buf.  However I can't figure out a testcase to verify
> this.  I think the fix would be to simply assign buf = (char *) "".
> Thoughts?

Yes.  What an ugly function.  Here's the patch, which seems OK.  Shame
about the cast, but the rest of the function does a similar thing too.

Neil.

	* tradcpp.c (special_symbol): Assign an null string rather
	than writing to an unallocated buffer.

Index: tradcpp.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tradcpp.c,v
retrieving revision 1.11
diff -u -p -r1.11 tradcpp.c
--- tradcpp.c	2000/08/29 18:37:37	1.11
+++ tradcpp.c	2000/11/06 18:54:03
@@ -2075,7 +2075,7 @@ special_symbol (hp, op)
 	  sprintf (buf, "\"%s\"", string);
 	}
       else
-	strcpy (buf, "\"\"");
+	buf = (char *) "";
 
       break;
     }


----- End forwarded message -----


More information about the Gcc-bugs mailing list