From 466adf661f1452e8cb8226faf7369e231aee9af3 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 19 Aug 2019 03:33:46 +0200 Subject: Fix memory leak in data writer error code paths Signed-off-by: David Oberhollenzer --- lib/sqfs/data_writer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sqfs/data_writer.c b/lib/sqfs/data_writer.c index c584f1e..d88c50e 100644 --- a/lib/sqfs/data_writer.c +++ b/lib/sqfs/data_writer.c @@ -307,8 +307,10 @@ int write_data_from_fd(data_writer_t *data, file_info_t *fi, if (!(blk_flags & (BLK_FIRST_BLOCK | BLK_LAST_BLOCK))) { blk_flags |= BLK_LAST_BLOCK; - if (add_sentinel_block(data, fi, blk_flags)) + if (add_sentinel_block(data, fi, blk_flags)) { + free(blk); return -1; + } } if (handle_fragment(data, blk)) @@ -440,8 +442,10 @@ int write_data_from_fd_condensed(data_writer_t *data, file_info_t *fi, if (!(blk_flags & (BLK_FIRST_BLOCK | BLK_LAST_BLOCK))) { blk_flags |= BLK_LAST_BLOCK; - if (add_sentinel_block(data, fi, blk_flags)) + if (add_sentinel_block(data, fi, blk_flags)) { + free(blk); return -1; + } } if (handle_fragment(data, blk)) -- cgit v1.2.3