Anonymous - 2011-04-03


I noticed that p7zip segfaults when I interrupt the update process ( which I described in detail in this bug report : )

I investigated it earlier today and found that the issue arises here :

    In 7zUpdate.cpp :
Line 1000 :  RINOK(encoder.Encode(....

If the result is not S_OK, the Update function returns and the local variables are destructed, which causes the decoder thread to segfault ( probably accessing a deallocated variable ).
I found that I could fix this by replacing the "RINOK(encoder.Encode(…." call with the following :

HRESULT encodeResult = encoder.Encode(...)
if(encodeResult!=S_OK) {        
    return encodeResult;    

Could someone familiar with the codebase comment on the accuracy of this solution?