summaryrefslogtreecommitdiffstats
path: root/fb-helper.c
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-08-15 23:27:45 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-08-15 23:27:45 +0200
commit9329567a8ca6207c9fe7434e6f55a1e8d1a01e07 (patch)
tree2b220ccfabfbd824ce42b4b1e07ba85ce07a8a50 /fb-helper.c
parent557565e33167d7fa93d0daa26cb19c182a4a942e (diff)
fb-helper: Fix improper handling of failing realloc() in load_file()
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'fb-helper.c')
-rw-r--r--fb-helper.c6
1 files 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);