sdiff(1): Fix potential NULL deref in cleanup path

In the presence of the --diff-pid argument, it is possible for 'diffpipe' to be
NULL.  Only fclose() it if it was initialized.

Reported by:	Coverity
CID:		1355183
Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Conrad Meyer 2016-05-10 20:09:40 +00:00
parent 51702162cc
commit a60711fd00
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=299385

View file

@ -430,7 +430,8 @@ main(int argc, char **argv)
/* Close open files and pipe, delete temps */
fclose(file1);
fclose(file2);
fclose(diffpipe);
if (diffpipe != NULL)
fclose(diffpipe);
if (tmp1)
if (unlink(tmp1))
warn("Error deleting %s.", tmp1);