[PATCH 18/32] [libx11] Tracked variable "size" was passed to a negative sink.

Erkki Seppälä erkki.seppala at vincit.fi
Wed Jan 26 23:54:01 PST 2011


Fixed the handling of the extremely unlikely situation of fstat failing

Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira at nokia.com>
Signed-off-by: Erkki Seppälä <erkki.seppala at vincit.fi>
---
 src/Xrm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/Xrm.c b/src/Xrm.c
index 3e68c37..b243d60 100644
--- a/src/Xrm.c
+++ b/src/Xrm.c
@@ -1595,6 +1595,12 @@ ReadInFile(_Xconst char *filename)
      * to the size returned by fstat.
      */
     GetSizeOfFile(fd, size);
+    
+    /* There might have been a problem trying to stat a file */
+    if (size == -1) {
+	close (fd);
+	return (char *)NULL;
+    }
 
     if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */
 	close(fd);
-- 
1.7.0.4



More information about the xorg-devel mailing list