Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: close file when return error #1723

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/dictzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,9 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header
if ( ftell( str ) != header->headerLength + 1 ) {
err_internal( __func__, "File position (%lu) != header length + 1 (%d)\n", ftell( str ), header->headerLength + 1 );
fclose( str );
if ( header->chunks )
if ( header->chunks ) {
free( header->chunks );
}
return DZ_ERR_INVALID_FORMAT;
}

Expand All @@ -435,8 +436,10 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header
/* Compute offsets */
header->offsets = xmalloc( sizeof( header->offsets[ 0 ] ) * header->chunkCount );
if ( header->offsets == 0 ) {
if ( header->chunks )
if ( header->chunks ) {
free( header->chunks );
}
fclose( str );
return DZ_ERR_NOMEMORY;
}

Expand Down
Loading