diff options
author | Eric Sesterhenn <eric.sesterhenn@lsexperts.de> | 2009-10-20 08:20:25 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-10-20 08:20:25 -0700 |
commit | f373e193a48eaf6d799d0b6ad32fd58d8ae8b3bd (patch) | |
tree | 9d77519e94cf65acb4eda3d43c6c9e8dee01cb74 | |
parent | 4ec346977273cc217b22a9225cb0d90351e6069c (diff) |
Bug 24635: File Descriptor leaks in libxaw-1.0.7
http://bugs.freedesktop.org/show_bug.cgi?id=24635
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r-- | src/AsciiSrc.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/AsciiSrc.c b/src/AsciiSrc.c index eb569fc..f3f013e 100644 --- a/src/AsciiSrc.c +++ b/src/AsciiSrc.c @@ -1292,10 +1292,14 @@ WriteToFile(String string, String name, unsigned length) { int fd; - if ((fd = creat(name, 0666)) == -1 - || write(fd, string, length) == -1) + if (fd = creat(name, 0666) == -1) return (False); + if (write(fd, string, length) == -1) { + close(fd); + return (False); + } + if (close(fd) == -1) return (False); @@ -1349,8 +1353,10 @@ WritePiecesToFile(AsciiSrcObject src, String name) return (False); for (piece = src->ascii_src.first_piece; piece; piece = piece->next) - if (write(fd, piece->text, piece->used) == -1) + if (write(fd, piece->text, piece->used) == -1) { + close(fd); return (False); + } if (close(fd) == -1) return (False); |