summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErkki Seppälä <erkki.seppala@vincit.fi>2011-01-31 14:02:06 +0200
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-02-01 23:46:13 -0800
commitbe3e6c205d94dedc1cdebf5d17b987f0f828377a (patch)
treeed04011712e1ee35f53de53773886e3c62bf9451
parent3fae16c64d6ef76fd4a25a54c7f7de76596457db (diff)
Xrm: Handle the extremely unlikely situation of fstat failing
Tracked variable "size" was passed to a negative sink. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com> Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/Xrm.c6
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;