Skip to content

Commit

Permalink
fix: double release memory (#1722)
Browse files Browse the repository at this point in the history
* fix: double release memory
  • Loading branch information
xiaoyifang authored Aug 10, 2024
1 parent 2dcf2a3 commit 752b880
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dictzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 752b880

Please sign in to comment.