From e0805be4909e47dac47bab9d0caf3725da43e645 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Wed, 1 Aug 2018 09:59:45 +0000 Subject: [PATCH 015/185] fix leak on error, found by coverity. --- src/compress.c | 5 +++++-- 1 file changed, 4 insertions(+), 1 deletions(-) diff --git a/src/compress.c b/src/compress.c index 5d565d5..ec26595 100644 --- a/src/compress.c +++ b/src/compress.c @@ -264,8 +264,11 @@ file_zmagic(struct magic_set *ms, const struct buffer *b, const char *name) * XXX: If file_buffer fails here, we overwrite * the compressed text. FIXME. */ - if (file_buffer(ms, -1, NULL, buf, nbytes) == -1) + if (file_buffer(ms, -1, NULL, buf, nbytes) == -1) { + if (file_pop_buffer(ms, pb) != NULL) + abort(); goto error; + } if ((rbuf = file_pop_buffer(ms, pb)) != NULL) { if (file_printf(ms, "%s", rbuf) == -1) { free(rbuf); -- 1.8.3.1