summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHristo Venev <hristo@venev.name>2020-06-09 13:17:02 +0000
committerHristo Venev <hristo@venev.name>2020-06-09 13:19:12 +0000
commitb2c4649aaa54ce40e8556b70e812132233f832b7 (patch)
treef095d264a749a7c6376516fcbefedc3322c69bc2
parent586990981a2cf0b4522451178ac0882967811149 (diff)
Fix double free when compressing empty files.
-rw-r--r--compress.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/compress.c b/compress.c
index 3accc9a..59bd35c 100644
--- a/compress.c
+++ b/compress.c
@@ -29,7 +29,8 @@ static ssize_t read_data(FILE *in, uint8_t **pdata) {
if(ferror_unlocked(in)) goto fail;
uint8_t *r = realloc(data, len);
- if(r) data = r;
+ if(len && !r) goto fail;
+ data = r;
*pdata = data;
return len;