[PATCH v2 14/25] [libx11] Fixed the handling of the extremely unlikely situation of fstat failing
Erkki Seppälä
erkki.seppala at vincit.fi
Mon Jan 31 04:02:06 PST 2011
Tracked variable "size" was passed to a negative sink.
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..fbc8ad2 100644
--- a/src/Xrm.c
+++ b/src/Xrm.c
@@ -1596,6 +1596,12 @@ ReadInFile(_Xconst char *filename)
*/
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);
return (char *)NULL;
--
1.7.0.4
More information about the xorg-devel
mailing list