From b2c4649aaa54ce40e8556b70e812132233f832b7 Mon Sep 17 00:00:00 2001 From: Hristo Venev Date: Tue, 9 Jun 2020 13:17:02 +0000 Subject: Fix double free when compressing empty files. --- compress.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- cgit