summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sesterhenn <eric.sesterhenn@lsexperts.de>2009-10-20 08:20:25 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2018-09-30 15:06:12 -0700
commite18ef34ee7694b9b423684eff1ed040859e4cd53 (patch)
tree03a8525ad90d45712c5fa06e9f4fd12402840232
parent62e18b8884efd39e8d764442f7b354d3e34fefbd (diff)
Bug 24635: File Descriptor leaks in libxaw-1.0.7
http://bugs.freedesktop.org/show_bug.cgi?id=24635 (Adapted from libXaw commit f373e193a48eaf6d799d0b6ad32fd58d8ae8b3bd.) Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/AsciiSrc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/AsciiSrc.c b/src/AsciiSrc.c
index cdc6277..0581040 100644
--- a/src/AsciiSrc.c
+++ b/src/AsciiSrc.c
@@ -907,10 +907,14 @@ WriteToFile(_Xconst _XtString string, _Xconst _XtString name)
{
int fd;
- if ( ((fd = creat(name, 0666)) == -1 ) ||
- (write(fd, string, sizeof(unsigned char) * strlen(string)) == -1) )
+ if ((fd = creat(name, 0666)) == -1)
return(FALSE);
+ if (write(fd, string, sizeof(unsigned char) * strlen(string)) == -1) {
+ close(fd);
+ return(FALSE);
+ }
+
if ( close(fd) == -1 )
return(FALSE);