fix: double release memory (#1722)

* fix: double release memory
This commit is contained in:
xiaoyifang 2024-08-10 14:59:50 +08:00 committed by GitHub
parent 2dcf2a3bad
commit 752b880f24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -371,8 +371,10 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header
if ( pt == buffer + sizeof( buffer ) ) { if ( pt == buffer + sizeof( buffer ) ) {
err_fatal( __func__, "too long FNAME field in dzip file \"%s\"\n", filename ); err_fatal( __func__, "too long FNAME field in dzip file \"%s\"\n", filename );
fclose( str ); fclose( str );
if ( header->chunks ) if ( header->chunks ) {
free( header->chunks ); free( header->chunks );
header->chunks = NULL;
}
return DZ_ERR_INVALID_FORMAT; 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 ) ) { if ( pt == buffer + sizeof( buffer ) ) {
err_fatal( __func__, "too long COMMENT field in dzip file \"%s\"\n", filename ); err_fatal( __func__, "too long COMMENT field in dzip file \"%s\"\n", filename );
fclose( str ); fclose( str );
if ( header->chunks ) if ( header->chunks ) {
free( header->chunks ); free( header->chunks );
header->chunks = NULL;
}
return DZ_ERR_INVALID_FORMAT; return DZ_ERR_INVALID_FORMAT;
} }
} }
@ -418,6 +422,7 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header
fclose( str ); fclose( str );
if ( header->chunks ) { if ( header->chunks ) {
free( header->chunks ); free( header->chunks );
header->chunks = NULL;
} }
return DZ_ERR_INVALID_FORMAT; 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->offsets == 0 ) {
if ( header->chunks ) { if ( header->chunks ) {
free( header->chunks ); free( header->chunks );
header->chunks = NULL;
} }
fclose( str ); fclose( str );
return DZ_ERR_NOMEMORY; return DZ_ERR_NOMEMORY;