From 752b880f248616fb32c1c2c44ac9ed7dac6d1b2a Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Sat, 10 Aug 2024 14:59:50 +0800 Subject: [PATCH] fix: double release memory (#1722) * fix: double release memory --- src/dictzip.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dictzip.c b/src/dictzip.c index 7615c873..60496075 100644 --- a/src/dictzip.c +++ b/src/dictzip.c @@ -371,8 +371,10 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header if ( pt == buffer + sizeof( buffer ) ) { err_fatal( __func__, "too long FNAME field in dzip file \"%s\"\n", filename ); fclose( str ); - if ( header->chunks ) + if ( header->chunks ) { free( header->chunks ); + header->chunks = NULL; + } return DZ_ERR_INVALID_FORMAT; } } @@ -393,8 +395,10 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header if ( pt == buffer + sizeof( buffer ) ) { err_fatal( __func__, "too long COMMENT field in dzip file \"%s\"\n", filename ); fclose( str ); - if ( header->chunks ) + if ( header->chunks ) { free( header->chunks ); + header->chunks = NULL; + } return DZ_ERR_INVALID_FORMAT; } } @@ -418,6 +422,7 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header fclose( str ); if ( header->chunks ) { free( header->chunks ); + header->chunks = NULL; } return DZ_ERR_INVALID_FORMAT; } @@ -438,6 +443,7 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header if ( header->offsets == 0 ) { if ( header->chunks ) { free( header->chunks ); + header->chunks = NULL; } fclose( str ); return DZ_ERR_NOMEMORY;