Hi, there is an inconsistency between sqlite implementation and documentation
of zlib API deflate in the file /ext/misc/zipfile.c:1003.
1000 deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
1001 res = deflate(&str, Z_FINISH);
1002
1003 if( res==Z_STREAM_END ){
1004 *ppOut = aOut;
1005 *pnOut = (int)str.total_out;
1006 }else{
1007 sqlite3_free(aOut);
1008 *pzErr = sqlite3_mprintf("zipfile: deflate() error");
1009 rc = SQLITE_ERROR;
1010 }
1011 deflateEnd(&str);
According to the description of zlib API deflate, when calling deflate with
parameter Z_FINISH, it must be called again with much more output space if
returning Z_OK or Z_BUF_ERROR. However, in the implementation of sqlite, it
didn't.
The description of zlib API deflate is shown as bellow:
If the parameter flush is set to Z_FINISH, pending input is processed, pending
output is flushed and deflate returns with Z_STREAM_END if there was enough
output space. If deflate returns with Z_OK or Z_BUF_ERROR, this function must
be called again with Z_FINISH and more output space (updated avail_out) but no
more input data, until it returns with Z_STREAM_END or an error. After deflate
has returned Z_STREAM_END, the only possible operations on the stream are
deflateReset or deflateEnd.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users