diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-04-22 13:23:09 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-04-23 23:07:59 -0700 |
commit | 980e9f851e47d31eed9635a6399a23d1456548d0 (patch) | |
tree | 38bc1e7c8ce215527c4050e37d16a0a30bc51a52 /src | |
parent | 81608285e11f2455800001a965dfece878861162 (diff) | |
download | xorg-lib-libXpm-980e9f851e47d31eed9635a6399a23d1456548d0.tar.gz |
Close fd if fdopen() or xpmPipeThrough() fails in OpenWriteFile()
Fixes leak found by parfait 1.1 bug checking tool:
File Descriptor Leak: Leaked File Descriptor fd
at line 350 of lib/libXpm/src/WrFFrI.c in function 'OpenWriteFile'.
fd initialized at line 332 with open
fd leaks when strcmp(".Z", (filename + (len - 2))) != 0 at line 337
and strcmp(".gz", (filename + (len - 3))) != 0 at line 340.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/WrFFrI.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/WrFFrI.c b/src/WrFFrI.c index b592fa1..d074516 100644 --- a/src/WrFFrI.c +++ b/src/WrFFrI.c @@ -346,8 +346,10 @@ OpenWriteFile( mdata->stream.file = fdopen(fd, "w"); mdata->type = XPMFILE; } - if (!mdata->stream.file) + if (!mdata->stream.file) { + close(fd); return (XpmOpenFailed); + } } return (XpmSuccess); } |