diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-04-21 15:49:33 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-04-21 15:55:18 -0700 |
commit | 26fb314644fd01928fc881e72e36b2c6bdda5b3b (patch) | |
tree | 447300359b44b908386d1bcbd9234fb4aa2ad24c | |
parent | a5630e166921b5b5322b30fb152df01bb6536e42 (diff) |
Fix fd leak when fdopen() fails in InitStringOrFile()
Found by parfait 1.1p2 bug checking tool:
File Descriptor Leak: Leaked File Descriptor fd
at line 1507 of src/AsciiSrc.c in function 'InitStringOrFile'.
fd initialized at line 1488 with open
fd leaks when open(src->ascii_src.string, open_mode, 438) != -1 at line 1488.
at line 1276 of src/MultiSrc.c in function 'InitStringOrFile'.
fd initialized at line 1257 with open
fd leaks when open(src->multi_src.string, open_mode, 438) != -1 at line 1257.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/AsciiSrc.c | 2 | ||||
-rw-r--r-- | src/MultiSrc.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/AsciiSrc.c b/src/AsciiSrc.c index b28b2c4..a37b6a1 100644 --- a/src/AsciiSrc.c +++ b/src/AsciiSrc.c @@ -1491,6 +1491,8 @@ InitStringOrFile(AsciiSrcObject src, Bool newString) src->ascii_src.length = (XawTextPosition)ftell(file); return (file); } + else + close(fd); } { String params[2]; diff --git a/src/MultiSrc.c b/src/MultiSrc.c index 148a178..33aa06a 100644 --- a/src/MultiSrc.c +++ b/src/MultiSrc.c @@ -1260,6 +1260,8 @@ InitStringOrFile(MultiSrcObject src, Bool newString) src->multi_src.length = (XawTextPosition)ftell(file); return(file); } + else + close(fd); } { String params[2]; |