NULL strings cause "segmenation fault"

Gary Isliefson (gislief@wpg.esc.lmco.com)
Mon, 23 Sep 1996 11:20:13 -0500 (CDT)


Hi I'm not sure if this is the correct place to ask this question but I'm
getting a "segmentation fault" when I perform some string operations. In
fact I've isolated the code to the following:

char *s ;
char *t ;
.
.
.
if (strcmp(s, t) == 0)
.
.

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.

I've seen the same problem on the "getenv" function as well.

I tried updating the compiler from GCC 2.6.3 to 2.7.2 - no help. I tried
updating the kernel from 1.2.3 to 1.2.13 - no help. I think its in a LIB
file somewhere but not sure which one or how to correct it if it is a LIB
problem.

If anyone has experienced this I'd like to know the history on it. Thanks
in advance for any help.

***********************************************************
* Gary Isliefson * Lockheed Martin *
* Design Engineer * Electronics Canada Inc. *
* Ph. (204) 253-3173 * Winnipeg, Manitoba, Cda *
* Fax (204) 253-3101 * 101-51 Burmac Rd *
* Email Address: * R2J 4C9 *
* gislief@wpg.esc.lmco.com * *
***********************************************************