diff options
author | Erkki Seppälä <erkki.seppala@vincit.fi> | 2011-01-31 14:02:06 +0200 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-01 23:46:13 -0800 |
commit | be3e6c205d94dedc1cdebf5d17b987f0f828377a (patch) | |
tree | ed04011712e1ee35f53de53773886e3c62bf9451 | |
parent | 3fae16c64d6ef76fd4a25a54c7f7de76596457db (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.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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; |