Skip to content

Commit

Permalink
avoid potential NULL pointer dereference when ComPath = 0, use empty …
Browse files Browse the repository at this point in the history
…string instead
  • Loading branch information
PerditionC committed Jul 10, 2021
1 parent dacdacd commit e3c5d68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/comfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@

char *comFile(void)
{ char *fnam;

if(inInit || (fnam = getEnv("COMSPEC")) == 0)

if(inInit || (fnam = getEnv("COMSPEC")) == 0) {
/* ComPath may be a NULL reference */
if (!ComPath) return strdup("");
return strdup(ComPath);
}

return fnam;
}

0 comments on commit e3c5d68

Please sign in to comment.