Module: wine Branch: master Commit: 6fab1e86f3ad6ac6c3e9d07f7f716ad348adb786 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6fab1e86f3ad6ac6c3e9d07f7f...
Author: Eric Pouech eric.pouech@orange.fr Date: Sun Nov 15 22:07:44 2009 +0100
msvcrt: In undname functions, no longer use a fixed-size array for storing internal information.
---
dlls/msvcrt/tests/cpp.c | 2 ++ dlls/msvcrt/undname.c | 28 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcrt/tests/cpp.c b/dlls/msvcrt/tests/cpp.c index d640d67..3b98423 100644 --- a/dlls/msvcrt/tests/cpp.c +++ b/dlls/msvcrt/tests/cpp.c @@ -1032,6 +1032,8 @@ static void test_demangle(void) /* 111 */ {"?f@T@@QAEHQCY1BE@BO@D@Z", "public: int __thiscall T::f(char (volatile * const)[20][30])"}, /* 112 */ {"?f@T@@QAEHQAY2BE@BO@CI@D@Z", "public: int __thiscall T::f(char (* const)[20][30][40])"}, /* 113 */ {"?f@T@@QAEHQAY1BE@BO@$$CBD@Z", "public: int __thiscall T::f(char const (* const)[20][30])"}, +/* 114 */ {"??0?$Foo@U?$vector_c@H$00$01$0?1$0A@$0A@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@@mpl@boost@@@@QAE@XZ", + "public: __thiscall Foo<struct boost::mpl::vector_c<int,1,2,-2,0,0,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647>>::Foo<struct boost::mpl::vector_c<int,1,2,-2,0,0,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647>>(void)"},
}; int i, num_test = (sizeof(test)/sizeof(test[0])); diff --git a/dlls/msvcrt/undname.c b/dlls/msvcrt/undname.c index 119b44d..cb07905 100644 --- a/dlls/msvcrt/undname.c +++ b/dlls/msvcrt/undname.c @@ -73,13 +73,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); * */
-#define MAX_ARRAY_ELTS 32 struct array { unsigned start; /* first valid reference in array */ unsigned num; /* total number of used elts */ unsigned max; - char* elts[MAX_ARRAY_ELTS]; + unsigned alloc; + char** elts; };
/* Structure holding a parsed symbol */ @@ -174,7 +174,8 @@ static void und_free_all(struct parsed_symbol* sym) */ static void str_array_init(struct array* a) { - a->start = a->num = a->max = 0; + a->start = a->num = a->max = a->alloc = 0; + a->elts = NULL; }
/****************************************************************** @@ -184,10 +185,25 @@ static void str_array_init(struct array* a) static BOOL str_array_push(struct parsed_symbol* sym, const char* ptr, int len, struct array* a) { + char** new; + assert(ptr); assert(a); - if (a->num >= MAX_ARRAY_ELTS) return FALSE;
+ if (!a->alloc) + { + new = und_alloc(sym, (a->alloc = 32) * sizeof(a->elts[0])); + if (!new) return FALSE; + a->elts = new; + } + else if (a->max >= a->alloc) + { + new = und_alloc(sym, (a->alloc * 2) * sizeof(a->elts[0])); + if (!new) return FALSE; + memcpy(new, a->elts, a->alloc * sizeof(a->elts[0])); + a->alloc *= 2; + a->elts = new; + } if (len == -1) len = strlen(ptr); a->elts[a->num] = und_alloc(sym, len + 1); assert(a->elts[a->num]); @@ -1332,8 +1348,8 @@ static BOOL symbol_demangle(struct parsed_symbol* sym) switch (do_after) { case 1: case 2: - sym->stack.num = sym->stack.max = 1; - sym->stack.elts[0] = dashed_null; + if (!str_array_push(sym, dashed_null, -1, &sym->stack)) + return FALSE; break; case 4: sym->result = (char*)function_name;