Anonymous - 2011-04-03

Hi,

I noticed that p7zip segfaults when I interrupt the update process ( which I described in detail in this bug report : https://sourceforge.net/tracker/?func=detail&aid=3207473&group_id=111810&atid=660493 )

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) {        
    threadDecoder.Thread.Close();
    return encodeResult;    
}

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