summaryrefslogtreecommitdiffstats
path: root/src/simfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/simfs.c')
-rw-r--r--src/simfs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/simfs.c b/src/simfs.c
index 0b554868..d743cd49 100644
--- a/src/simfs.c
+++ b/src/simfs.c
@@ -772,8 +772,12 @@ char *sim_fs_get_cached_image(struct sim_fs *fs, int id)
return NULL;
image_length = st_buf.st_size;
+ buffer = g_try_new0(char, image_length + 1);
- buffer = g_try_malloc0(image_length + 1);
+ if (buffer == NULL) {
+ TFR(close(fd));
+ return NULL;
+ }
len = TFR(read(fd, buffer, image_length));