From 6fab1e86f3ad6ac6c3e9d07f7f716ad348adb786 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Sun, 15 Nov 2009 22:07:44 +0100 Subject: [PATCH] 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 d640d674e3e..3b98423b6e1 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>::Foo>(void)"}, }; int i, num_test = (sizeof(test)/sizeof(test[0])); diff --git a/dlls/msvcrt/undname.c b/dlls/msvcrt/undname.c index 119b44dc050..cb079050bda 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; -- 2.11.4.GIT