Piotr Caban : msvcp90: Allocate facetvec of size at least 40 in locale:: _Locimp::_Locimp_Addfac.
Module: wine Branch: master Commit: a8399b38724b674fd0920ea8c9095df123e04ac6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a8399b38724b674fd0920ea8c9... Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed May 4 14:29:35 2016 +0200 msvcp90: Allocate facetvec of size at least 40 in locale::_Locimp::_Locimp_Addfac. Matlab depends on facetvec internal buffer not being reallocated. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcp90/locale.c | 4 ++-- dlls/msvcp90/tests/misc.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c index d0fbee0..24cacc7 100644 --- a/dlls/msvcp90/locale.c +++ b/dlls/msvcp90/locale.c @@ -10204,8 +10204,8 @@ void __cdecl locale__Locimp__Locimp_Addfac(locale__Locimp *locimp, locale_facet MSVCP_size_t new_size = id+1; locale_facet **new_facetvec; - if(new_size < locale_id__Id_cnt+1) - new_size = locale_id__Id_cnt+1; + if(new_size < 40) + new_size = 40; new_facetvec = MSVCRT_operator_new(sizeof(locale_facet*)*new_size); if(!new_facetvec) { diff --git a/dlls/msvcp90/tests/misc.c b/dlls/msvcp90/tests/misc.c index 34d6090..2c61bcc 100644 --- a/dlls/msvcp90/tests/misc.c +++ b/dlls/msvcp90/tests/misc.c @@ -81,6 +81,22 @@ typedef struct { float imag; } complex_float; +typedef struct { + void *vtable; + size_t refs; +} locale_facet; + +typedef unsigned char MSVCP_bool; + +typedef struct _locale__Locimp { + locale_facet facet; + locale_facet **facetvec; + size_t facet_cnt; + int catmask; + MSVCP_bool transparent; + basic_string_char name; +} locale__Locimp; + static void* (__cdecl *p_set_invalid_parameter_handler)(void*); static _locale_t (__cdecl *p__get_current_locale)(void); static void (__cdecl *p__free_locale)(_locale_t); @@ -102,6 +118,7 @@ static MSVCP__Ctypevec* (__cdecl *p__Getctype)(MSVCP__Ctypevec*); static /*MSVCP__Collvec*/ULONGLONG (__cdecl *p__Getcoll)(void); static wctrans_t (__cdecl *p_wctrans)(const char*); static wint_t (__cdecl *p_towctrans)(wint_t, wctrans_t); +static void (__cdecl *p_locale__Locimp__Locimp_Addfac)(locale__Locimp*,locale_facet*,size_t); #undef __thiscall #ifdef __i386__ @@ -250,6 +267,8 @@ static BOOL init(void) SET(p_std_Ctraits_long_double__Isnan, "?_Isnan@?$_Ctraits(a)O@std@@SA_NO(a)Z"); if(sizeof(void*) == 8) { /* 64-bit initialization */ + SET(p_locale__Locimp__Locimp_Addfac, + "?_Locimp_Addfac(a)_Locimp@locale(a)std@@CAXPEAV123(a)PEAVfacet@23(a)_K@Z"); SET(p_char_assign, "?assign@?$char_traits(a)D@std@@SAXAEADAEBD(a)Z"); SET(p_wchar_assign, "?assign@?$char_traits(a)_W@std@@SAXAEA_WAEB_W(a)Z"); SET(p_short_assign, "?assign@?$char_traits(a)G@std@@SAXAEAGAEBG(a)Z"); @@ -310,6 +329,8 @@ static BOOL init(void) SET(p_complex_float_pow_cf, "??$pow(a)M@std@@YA?AV?$complex(a)M@0(a)AEBV10@AEBM(a)Z"); } else { + SET(p_locale__Locimp__Locimp_Addfac, + "?_Locimp_Addfac(a)_Locimp@locale(a)std@@CAXPAV123(a)PAVfacet@23(a)I@Z"); #ifdef __arm__ SET(p_char_assign, "?assign@?$char_traits(a)D@std@@SAXAADABD(a)Z"); SET(p_wchar_assign, "?assign@?$char_traits(a)_W@std@@SAXAA_WAB_W(a)Z"); @@ -1050,6 +1071,19 @@ static void test_vbtable_size_exports(void) } } + + +static void test_locale__Locimp__Locimp_Addfac(void) +{ + locale__Locimp locimp; + locale_facet facet; + + memset(&locimp, 0, sizeof(locimp)); + memset(&facet, 0, sizeof(facet)); + p_locale__Locimp__Locimp_Addfac(&locimp, &facet, 1); + ok(locimp.facet_cnt == 40, "locimp.facet_cnt = %d\n", (int)locimp.facet_cnt); +} + START_TEST(misc) { if(!init()) @@ -1068,6 +1102,7 @@ START_TEST(misc) test_Ctraits_math_functions(); test_complex(); test_vbtable_size_exports(); + test_locale__Locimp__Locimp_Addfac(); ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");
participants (1)
-
Alexandre Julliard