diff --git a/crengine/src/lvstream/lvzipdecodestream.cpp b/crengine/src/lvstream/lvzipdecodestream.cpp index b334af2c8..2fa4c31ef 100644 --- a/crengine/src/lvstream/lvzipdecodestream.cpp +++ b/crengine/src/lvstream/lvzipdecodestream.cpp @@ -380,12 +380,12 @@ LVStream *LVZipDecodeStream::Create(LVStreamRef stream, lvpos_t pos, lString32 n if ( stream->Seek( pos, LVSEEK_SET, NULL )!=LVERR_OK ) return NULL; #endif - if ( packSize==0 && unpSize==0 ) { - // Can happen when local header does not carry these sizes - // Use the ones provided that come from zip central directory - packSize = srcPackSize; - unpSize = srcUnpSize; - } + + // When local header does not carry these sizes, use the ones + // that come from zip central directory + if ( packSize==0 ) packSize = srcPackSize; + if ( unpSize==0 ) unpSize = srcUnpSize; + if ((lvpos_t)(pos + packSize) > (lvpos_t)stream->GetSize()) return NULL; if (hdr.getMethod() == 0) {