Skip to content

Commit

Permalink
Fix minor memory leak with input preprocessor. (#150)
Browse files Browse the repository at this point in the history
If the read doesn't succeed, readfd still returns a malloc'ed buffer.
  • Loading branch information
keinflue committed Apr 16, 2021
1 parent 5bc78d5 commit da495f5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,10 +946,13 @@ open_altfile(filename, pf, pfd)
cmd = readfd(fd);
pclose(fd);
if (*cmd == '\0')
{
/*
* Pipe is empty. This means there is no alt file.
*/
free(cmd);
return (NULL);
}
return (cmd);
#endif /* HAVE_POPEN */
}
Expand Down

0 comments on commit da495f5

Please sign in to comment.