Skip to content

Commit

Permalink
opt: check result of inflateEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Dec 26, 2024
1 parent bddb3ea commit da3f367
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/dict/utils/indexedzip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,26 @@ bool IndexedZip::loadFile( uint32_t offset, vector< char > & data )
int ret = inflate( &stream, Z_FINISH );
if ( ret != Z_STREAM_END ) {
qDebug() << "Not zstream end! Stream total_in:" << stream.total_in << "total_out:" << stream.total_out
<< "msg:" << ( stream.msg ? stream.msg : "none" );
<< "msg:" << ( stream.msg ? stream.msg : "none" );

data.clear();

inflateEnd( &stream );
int endRet = inflateEnd( &stream );
if ( endRet != Z_OK ) {
qDebug() << "inflateEnd failed after inflate! msg:" << ( stream.msg ? stream.msg : "none" );
}

return false;
}

inflateEnd( &stream );
ret = inflateEnd( &stream );
if ( ret != Z_OK ) {
qDebug() << "inflateEnd failed! msg:" << ( stream.msg ? stream.msg : "none" );

data.clear();

return false;
}

return true;
}
Expand Down

0 comments on commit da3f367

Please sign in to comment.