Skip to content

Commit e3c5d68

Browse files
committed
avoid potential NULL pointer dereference when ComPath = 0, use empty string instead
1 parent dacdacd commit e3c5d68

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/comfile.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@
4444

4545
char *comFile(void)
4646
{ char *fnam;
47-
48-
if(inInit || (fnam = getEnv("COMSPEC")) == 0)
47+
48+
if(inInit || (fnam = getEnv("COMSPEC")) == 0) {
49+
/* ComPath may be a NULL reference */
50+
if (!ComPath) return strdup("");
4951
return strdup(ComPath);
52+
}
53+
5054
return fnam;
5155
}

0 commit comments

Comments
 (0)