diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-09-30 15:09:29 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-10-06 11:52:24 -0700 |
commit | 73a1e769dcf2a603fc63f5c36626c1c6db815f46 (patch) | |
tree | 786def576e25142a785ee570ae72f65c5e82668b | |
parent | bc1b4962f048cfa33b76be46493e10cfb256fe98 (diff) |
After fdopen(), use fclose() instead of close() in error path
Found by Oracle's Parfait 2.2 static analyzer:
Error: File Leak
File Leak [file-ptr-leak]:
Leaked File fp
at line 94 of lib/libXpm/src/RdFToBuf.c in function 'XpmReadFileToBuffer
'.
fp initialized at line 86 with fdopen
fp leaks when len < 0 at line 92.
Introduced-by: commit 8b3024e6871ce50b34bf2dff924774bd654703bc
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/RdFToBuf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/RdFToBuf.c b/src/RdFToBuf.c index 69e3347..1b386f8 100644 --- a/src/RdFToBuf.c +++ b/src/RdFToBuf.c @@ -90,7 +90,7 @@ XpmReadFileToBuffer( } len = stats.st_size; if (len < 0 || len >= SIZE_MAX) { - close(fd); + fclose(fp); return XpmOpenFailed; } ptr = (char *) XpmMalloc(len + 1); |