From 7016a638fe7aa8c2fe93b2dc67b304d86cb49f2a Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 4 Apr 2012 20:11:59 +0200 Subject: [PATCH] msvcp60: Use the correct vtable pointer for type_info objects. --- dlls/msvcp60/exception.c | 29 +++++++++++++++++++++++++++++ dlls/msvcp60/msvcp.h | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/dlls/msvcp60/exception.c b/dlls/msvcp60/exception.c index 6dfdb50d75f..609cb985090 100644 --- a/dlls/msvcp60/exception.c +++ b/dlls/msvcp60/exception.c @@ -61,6 +61,7 @@ typedef struct __cxx_exception_type void WINAPI _CxxThrowException(exception*,const cxx_exception_type*); /* vtables */ +extern const vtable_ptr MSVCP_type_info_vtable; extern const vtable_ptr MSVCP_exception_vtable; /* ??_7bad_alloc@std@@6B@ */ extern const vtable_ptr MSVCP_bad_alloc_vtable; @@ -74,6 +75,33 @@ extern const vtable_ptr MSVCP_invalid_argument_vtable; /* ??_7runtime_error@std@@6B@ */ extern const vtable_ptr MSVCP_runtime_error_vtable; +static void MSVCP_type_info_dtor(type_info * _this) +{ + free(_this->name); +} + +DEFINE_THISCALL_WRAPPER(MSVCP_type_info_vector_dtor,8) +void * __thiscall MSVCP_type_info_vector_dtor(type_info * _this, unsigned int flags) +{ + TRACE("(%p %x)\n", _this, flags); + if (flags & 2) + { + /* we have an array, with the number of elements stored before the first object */ + int i, *ptr = (int *)_this - 1; + + for (i = *ptr - 1; i >= 0; i--) MSVCP_type_info_dtor(_this + i); + MSVCRT_operator_delete(ptr); + } + else + { + MSVCP_type_info_dtor(_this); + if (flags & 1) MSVCRT_operator_delete(_this); + } + return _this; +} + +DEFINE_RTTI_DATA( type_info, 0, 0, NULL, NULL, NULL, ".?AVtype_info@@" ); + DEFINE_THISCALL_WRAPPER(MSVCP_exception_ctor, 8) exception* __thiscall MSVCP_exception_ctor(exception *this, const char *name) { @@ -703,6 +731,7 @@ const char* __thiscall MSVCP_runtime_error_what(runtime_error *this) #ifndef __GNUC__ void __asm_dummy_vtables(void) { #endif + __ASM_VTABLE(type_info,""); __ASM_VTABLE(exception, VTABLE_ADD_FUNC(MSVCP_exception_what) VTABLE_ADD_FUNC(MSVCP_exception__Doraise)); diff --git a/dlls/msvcp60/msvcp.h b/dlls/msvcp60/msvcp.h index 82d9d4c1588..27d53667b7e 100644 --- a/dlls/msvcp60/msvcp.h +++ b/dlls/msvcp60/msvcp.h @@ -83,7 +83,7 @@ extern void* (__cdecl *MSVCRT_set_new_handler)(void*); #define DEFINE_RTTI_DATA(name, off, base_classes, cl1, cl2, cl3, mangled_name) \ static const type_info name ## _type_info = { \ - &MSVCP_ ## name ## _vtable, \ + &MSVCP_type_info_vtable, \ NULL, \ mangled_name \ }; \