[lkml]   [1996]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: NULL strings cause "segmenation fault"
> It seems that if s or t are NULL pointers (as they are when first 
> allocated) then I get the fault. According to the MAN page on strcmp, if
> s or t are NULL then they are treated as if they point to NULL-terminated
> string. So I shouldn't have to check for this in my program.

1) char *s; doesn't *initialize* s to anything -- it just makes it use
some space... which may have a random value in it. That alone would
crash strcmp.

2) I've never seen a strcmp which was actually documented as treeting
NULL pointers specially. In particular, no linux version is
documented this way.

> I tried updating the compiler from GCC 2.6.3 to 2.7.2 - no help. I tried

Time to update your C programming textbook :-)

 \ /
  Last update: 2005-03-22 13:38    [W:0.026 / U:0.740 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site