
Question:
My C application has the following two lines:
char buf[1024]; sprintf(buf, "%s/game/rabbit/habit/cmd/talkPipe", getenv("APPLICATION_PATH"));
The application sporadically crashes with SIGSEGV in the following manner:
strlen(ff2ba231, 0, ffbfe1d0, 10, 7fff24d7, 0)+0x50 sprintf(ffbfe2a4, ff2ba231, 0, 74656400, 12, ff362ef2)+0x24 RabbitTalk(ffbfea80, ffbfee50, 1, d, ffbfea12, 0)+0x21c ...
Can anyone pass a hint on where/what might be the problem?
Thanx a lot,
Solution:1
Maybe because getenv returns NULL ?
Even if it's not the problem at hand you should check for NULL : most old style C functions don't.
Solution:2
getenv()
would return NULL
if the environment variable not exist (not exported), this cause the SIGSEGV
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon