Fixes bug 18887. Although the bug doesn't mention it this really is:

This commit is contained in:
sgehani%netscape.com 1999-11-17 05:40:00 +00:00
Родитель d7850c8844
Коммит a14a6d90e5
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -69,7 +69,6 @@
#include "zipstruct.h" #include "zipstruct.h"
#include "nsZipArchive.h" #include "nsZipArchive.h"
static PRUint16 xtoint(unsigned char *ii); static PRUint16 xtoint(unsigned char *ii);
static PRUint32 xtolong(unsigned char *ll); static PRUint32 xtolong(unsigned char *ll);
static PRUint16 ExtractMode(PRUint32 ext_attr); static PRUint16 ExtractMode(PRUint32 ext_attr);
@ -975,6 +974,7 @@ PRInt32 nsZipArchive::InflateItem( const nsZipItem* aItem, const char* aOutname,
PRBool bRead; PRBool bRead;
PRBool bWrote; PRBool bWrote;
PRBool bToFile; PRBool bToFile;
Bytef* old_next_out;
#if defined STANDALONE && defined WIN32 #if defined STANDALONE && defined WIN32
MSG msg; MSG msg;
@ -1003,9 +1003,6 @@ PRInt32 nsZipArchive::InflateItem( const nsZipItem* aItem, const char* aOutname,
goto cleanup; goto cleanup;
} }
//-- initialize crc
crc = crc32(0L, Z_NULL, 0);
//-- We should already be at the correct spot in the archive. //-- We should already be at the correct spot in the archive.
//-- ReadInitImpl did the seek(). //-- ReadInitImpl did the seek().
@ -1036,6 +1033,7 @@ PRInt32 nsZipArchive::InflateItem( const nsZipItem* aItem, const char* aOutname,
outpos = inpos = 0; outpos = inpos = 0;
zs.next_out = outbuf; zs.next_out = outbuf;
zs.avail_out = ZIP_BUFLEN; zs.avail_out = ZIP_BUFLEN;
crc = crc32(0L, Z_NULL, 0);
while ( zerr == Z_OK ) while ( zerr == Z_OK )
{ {
bRead = PR_FALSE; bRead = PR_FALSE;
@ -1090,10 +1088,12 @@ PRInt32 nsZipArchive::InflateItem( const nsZipItem* aItem, const char* aOutname,
if(bRead || bWrote) if(bRead || bWrote)
{ {
old_next_out = zs.next_out;
zerr = inflate( &zs, Z_PARTIAL_FLUSH ); zerr = inflate( &zs, Z_PARTIAL_FLUSH );
//-- incrementally update crc32 //-- incrementally update crc32
crc = crc32(crc, (const unsigned char*)outbuf, zs.total_out - outpos); crc = crc32(crc, (const unsigned char*)old_next_out, zs.next_out - old_next_out);
} }
else else
zerr = Z_STREAM_END; zerr = Z_STREAM_END;