mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Merge pull request #1723 from xiaoyifang/fix/file-close
fix: close file when return error
This commit is contained in:
commit
2dcf2a3bad
|
@ -416,8 +416,9 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header
|
||||||
if ( ftell( str ) != header->headerLength + 1 ) {
|
if ( ftell( str ) != header->headerLength + 1 ) {
|
||||||
err_internal( __func__, "File position (%lu) != header length + 1 (%d)\n", ftell( str ), header->headerLength + 1 );
|
err_internal( __func__, "File position (%lu) != header length + 1 (%d)\n", ftell( str ), header->headerLength + 1 );
|
||||||
fclose( str );
|
fclose( str );
|
||||||
if ( header->chunks )
|
if ( header->chunks ) {
|
||||||
free( header->chunks );
|
free( header->chunks );
|
||||||
|
}
|
||||||
return DZ_ERR_INVALID_FORMAT;
|
return DZ_ERR_INVALID_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,8 +436,10 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header
|
||||||
/* Compute offsets */
|
/* Compute offsets */
|
||||||
header->offsets = xmalloc( sizeof( header->offsets[ 0 ] ) * header->chunkCount );
|
header->offsets = xmalloc( sizeof( header->offsets[ 0 ] ) * header->chunkCount );
|
||||||
if ( header->offsets == 0 ) {
|
if ( header->offsets == 0 ) {
|
||||||
if ( header->chunks )
|
if ( header->chunks ) {
|
||||||
free( header->chunks );
|
free( header->chunks );
|
||||||
|
}
|
||||||
|
fclose( str );
|
||||||
return DZ_ERR_NOMEMORY;
|
return DZ_ERR_NOMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue