simfs: If buffer alloc fails, error out

This commit is contained in:
Denis Kenzior 2010-10-11 20:14:04 -05:00
parent f4c66f67df
commit 096634e798
1 changed files with 5 additions and 1 deletions

View File

@ -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));