Module: wine Branch: master Commit: 91fab7330997be5b1d18980e1237a33a022fb6e9 URL: https://gitlab.winehq.org/wine/wine/-/commit/91fab7330997be5b1d18980e1237a33...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Jun 4 10:48:00 2024 +0200
msvcrt: Use the copy_exception() helper in __CxxExceptionFilter.
---
dlls/msvcrt/cppexcept.h | 10 ++-------- dlls/msvcrt/except.c | 9 ++++++--- dlls/msvcrt/except_i386.c | 23 +---------------------- dlls/msvcrt/handler4.c | 9 ++++++--- 4 files changed, 15 insertions(+), 36 deletions(-)
diff --git a/dlls/msvcrt/cppexcept.h b/dlls/msvcrt/cppexcept.h index 690c1f5817f..cb0ce03c960 100644 --- a/dlls/msvcrt/cppexcept.h +++ b/dlls/msvcrt/cppexcept.h @@ -231,15 +231,9 @@ static inline const cxx_type_info *find_caught_type( cxx_exception_type *exc_typ }
/* copy the exception object where the catch block wants it */ -static inline void copy_exception( void *object, uintptr_t frame, int offset, UINT catch_flags, - const type_info *catch_ti, const cxx_type_info *type, uintptr_t base ) +static inline void copy_exception( void *object, void **dest, UINT catch_flags, + const cxx_type_info *type, uintptr_t base ) { - void **dest; - - if (!catch_ti || !catch_ti->mangled[0]) return; - if (!offset) return; - dest = (void **)(frame + offset); - if (catch_flags & TYPE_FLAG_REFERENCE) { *dest = get_this_pointer( &type->offsets, object ); diff --git a/dlls/msvcrt/except.c b/dlls/msvcrt/except.c index b6f2bb8784d..dd45defbbeb 100644 --- a/dlls/msvcrt/except.c +++ b/dlls/msvcrt/except.c @@ -111,9 +111,12 @@ void *find_catch_handler( void *object, uintptr_t frame, uintptr_t exc_base,
TRACE( "matched type %p in catchblock %d\n", type, i );
- /* copy the exception to its destination on the stack */ - copy_exception( object, frame, catchblock[i].offset, catchblock[i].flags, - catch_ti, type, exc_base ); + if (catch_ti && catch_ti->mangled[0] && catchblock[i].offset) + { + /* copy the exception to its destination on the stack */ + void **dest = (void **)(frame + catchblock[i].offset); + copy_exception( object, dest, catchblock[i].flags, type, exc_base ); + } } else { diff --git a/dlls/msvcrt/except_i386.c b/dlls/msvcrt/except_i386.c index f76762d3cb0..0c5d805721d 100644 --- a/dlls/msvcrt/except_i386.c +++ b/dlls/msvcrt/except_i386.c @@ -313,29 +313,8 @@ int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs, type = find_caught_type( (cxx_exception_type*)rec->ExceptionInformation[2], 0, ti, flags ); if (!type) return EXCEPTION_CONTINUE_SEARCH;
- if (copy) - { - void *object = (void *)rec->ExceptionInformation[1]; + if (copy) copy_exception( (void *)rec->ExceptionInformation[1], copy, flags, type, 0 );
- if (flags & TYPE_FLAG_REFERENCE) - { - *copy = get_this_pointer( &type->offsets, object ); - } - else if (type->flags & CLASS_IS_SIMPLE_TYPE) - { - memmove( copy, object, type->size ); - /* if it is a pointer, adjust it */ - if (type->size == sizeof(void*)) *copy = get_this_pointer( &type->offsets, *copy ); - } - else /* copy the object */ - { - if (type->copy_ctor) - call_copy_ctor( type->copy_ctor, copy, get_this_pointer(&type->offsets,object), - (type->flags & CLASS_HAS_VIRTUAL_BASE_CLASS) ); - else - memmove( copy, get_this_pointer(&type->offsets,object), type->size ); - } - } return EXCEPTION_EXECUTE_HANDLER; }
diff --git a/dlls/msvcrt/handler4.c b/dlls/msvcrt/handler4.c index 0f54ddd9f1f..2e6870ff645 100644 --- a/dlls/msvcrt/handler4.c +++ b/dlls/msvcrt/handler4.c @@ -528,9 +528,12 @@ static inline void find_catch_block4(EXCEPTION_RECORD *rec, CONTEXT *context,
TRACE("matched type %p in tryblock %d catchblock %d\n", type, i, j);
- /* copy the exception to its destination on the stack */ - copy_exception( (void *)rec->ExceptionInformation[1], orig_frame, - ci.offset, ci.flags, catch_ti, type, exc_base ); + if (catch_ti && catch_ti->mangled[0] && ci.offset) + { + /* copy the exception to its destination on the stack */ + void **dest = (void **)(orig_frame + ci.offset); + copy_exception( (void *)rec->ExceptionInformation[1], dest, ci.flags, type, exc_base ); + } } else {