From 9329567a8ca6207c9fe7434e6f55a1e8d1a01e07 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 15 Aug 2013 23:27:45 +0200 Subject: fb-helper: Fix improper handling of failing realloc() in load_file() Signed-off-by: Florian Pritz --- fb-helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fb-helper.c b/fb-helper.c index 6e2a7fb..b550887 100644 --- a/fb-helper.c +++ b/fb-helper.c @@ -68,11 +68,13 @@ int load_file(const char *fn, char **data, size_t *data_size) /* read the file in buf_size chunks and appened the data to *data */ while (!feof(fp)) { - *data = realloc(*data, *data_size + buf_size); - if (*data == NULL) { + char *tmp; + tmp = realloc(*data, *data_size + buf_size); + if (tmp == NULL) { perror("load_file"); return 1; } + *data = tmp; *data_size += fread(*data + *data_size, sizeof(char), buf_size, fp); -- cgit v1.2.3-24-g4f1b