help-gnu-utils
[Top][All Lists]
Advanced

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

Dereferencing a null pointer!


From: Bhaskar
Subject: Dereferencing a null pointer!
Date: Fri, 1 Dec 2000 18:02:51 -0800

Hi,
   I'm using gcc to compile my C programs on Solaris.Basically i'm porting a product from SVR4 to Solaris.It seems SVR4 UNIX allows dereferencing of null pointers(sic!) and the programmers of my product have taken advantage of this fact.
  Look at the following piece of code :
 
char *str=NULL;
...
...
...
printf("%s",str);
 
if str is not allocated any memory before the printf it still points to null and when i execute code like this on Solaris 7.0 i get Segmentation fault and core dump.But the same thing works fine on SVR4!(It gives the appearance to the programmer that data at address 0 is '\0' (integer 0)).
Changing the code is difficult as the logic is also built around this capability.
Please let me know if there are any gcc flags or patches or OS patches that i can install that will allow dereferencing of null pointers!
Thank You,
Bhaskar.
bhaskar@opussoft.com
dbnraju@hotmail.com
 

reply via email to

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