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:
cem 2016-05-10 20:09:40 +00:00
parent b05aea41fa
commit 0a07aade42

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);