Patches item #1544006, was opened at 2006-08-21 15:21 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=462818&aid=1544006&group_id=51305
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: David Hart (dghart) Assigned to: Nobody/Anonymous (nobody) Summary: Patch to stop wxBZipStream hanging on large archives Initial Comment: Hi Ryan, I've been using wxBZipStream on top of Mike Wetherell's wxArchive tarstreams, to peek inside tar.bz2 files in a filemanager. I've found one 'issue' and one bug. The issue is that you use #ifndef _WX_WXZSTREAM_H__ to protect the .h file. So does wx/zstream.h, which caused interesting problems until I twigged. Perhaps _WX_WXBZSTREAM_H__ ... The bug occurs with large archives, say 1MB or so. Trying to decompress them hangs the app in an infinite loop. I've traced the cause to this delectable line in wxBZipInputStream::OnSysRead nBufferPos += -(nRead - ( nRead += (WXBZBS - nBufferPos - ((bz_stream*&)hZip)->avail_in) )); Presumably this gets parsed from right to left, so because of the second +=, it simplifies to nBufferPos += -(nRead - nRead); and nBufferPos remains unchanged. In particular, if nBufferPos is 0 it stays 0; and if bufsize was originally 0 too, the function returns 0. This causes it to be called again with a bufsize of 0, and so ad infinitum. I have very little idea what *should* be happening here, but storing the amount of data remaining seemed like a good idea, and I'm pleased to say it works :) . I've tested with bzipped archives up to 600MB successfully (it took 6 minutes, mind you). Also, in the diff I've removed the "- nRead" from line 128 since this had just been set to zero. Regards, David Hart --- bzipstream.cpp 2006-08-21 14:25:00.000000000 +0100 +++ newbzipstream.cpp 2006-08-21 14:26:59.000000000 +0100 @@ -126,5 +126,5 @@ ((bz_stream*&)hZip)->next_out = &(((char*&)buffer)[nRead]); - ((bz_stream*&)hZip)->avail_out = bufsize - nRead; + ((bz_stream*&)hZip)->avail_out = bufsize; while (((bz_stream*&)hZip)->avail_out != 0) @@ -157,7 +157,5 @@ if (nRet == BZ_OK) { - nBufferPos += -(nRead - ( - nRead += (WXBZBS - nBufferPos - ((bz_stream*&)hZip)->avail_in) - )); + nBufferPos = WXBZBS - ((bz_stream*&)hZip)->avail_in; } else if(nRet == BZ_STREAM_END) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=462818&aid=1544006&group_id=51305 ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ wxCode-users mailing list wxCode-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxcode-users