From e18ef34ee7694b9b423684eff1ed040859e4cd53 Mon Sep 17 00:00:00 2001 From: Eric Sesterhenn Date: Tue, 20 Oct 2009 08:20:25 -0700 Subject: 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 --- src/AsciiSrc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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); -- cgit v1.2.3