msvcrt: Register exception object before unwinding.

Thrown object was incorrectly freed in following situation:
try {
     try {
         throw obj;
     } catch(...) {
         throw;
     }
} catch(...) {
     //use object here
}

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2016-03-21 19:16:06 +01:00 committed by Alexandre Julliard
parent fdcdbf306a
commit 3a0b3c5bc8

View file

@ -446,6 +446,8 @@ static inline void call_catch_block( PEXCEPTION_RECORD rec, cxx_exception_frame
TRACE("found catch(...) block\n");
}
__CxxRegisterExceptionObject(&rec, &nested_frame.frame_info);
/* unwind the stack */
RtlUnwind( catch_frame ? catch_frame : &frame->frame, 0, rec, 0 );
cxx_local_unwind( frame, descr, tryblock->start_level );
@ -457,12 +459,10 @@ static inline void call_catch_block( PEXCEPTION_RECORD rec, cxx_exception_frame
catchblock, catchblock->handler, &frame->ebp );
/* setup an exception block for nested exceptions */
nested_frame.frame.Handler = catch_function_nested_handler;
nested_frame.cxx_frame = frame;
nested_frame.descr = descr;
nested_frame.trylevel = nested_trylevel + 1;
__CxxRegisterExceptionObject(&rec, &nested_frame.frame_info);
__wine_push_frame( &nested_frame.frame );
addr = call_ebp_func( catchblock->handler, &frame->ebp );