Commit 6fab1e86 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

msvcrt: In undname functions, no longer use a fixed-size array for storing internal information.

parent c65106e1
...@@ -1032,6 +1032,8 @@ static void test_demangle(void) ...@@ -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])"}, /* 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])"}, /* 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])"}, /* 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])); int i, num_test = (sizeof(test)/sizeof(test[0]));
......
...@@ -73,13 +73,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); ...@@ -73,13 +73,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
* *
*/ */
#define MAX_ARRAY_ELTS 32
struct array struct array
{ {
unsigned start; /* first valid reference in array */ unsigned start; /* first valid reference in array */
unsigned num; /* total number of used elts */ unsigned num; /* total number of used elts */
unsigned max; unsigned max;
char* elts[MAX_ARRAY_ELTS]; unsigned alloc;
char** elts;
}; };
/* Structure holding a parsed symbol */ /* Structure holding a parsed symbol */
...@@ -174,7 +174,8 @@ static void und_free_all(struct parsed_symbol* sym) ...@@ -174,7 +174,8 @@ static void und_free_all(struct parsed_symbol* sym)
*/ */
static void str_array_init(struct array* a) 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) ...@@ -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, static BOOL str_array_push(struct parsed_symbol* sym, const char* ptr, int len,
struct array* a) struct array* a)
{ {
char** new;
assert(ptr); assert(ptr);
assert(a); 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); if (len == -1) len = strlen(ptr);
a->elts[a->num] = und_alloc(sym, len + 1); a->elts[a->num] = und_alloc(sym, len + 1);
assert(a->elts[a->num]); assert(a->elts[a->num]);
...@@ -1332,8 +1348,8 @@ static BOOL symbol_demangle(struct parsed_symbol* sym) ...@@ -1332,8 +1348,8 @@ static BOOL symbol_demangle(struct parsed_symbol* sym)
switch (do_after) switch (do_after)
{ {
case 1: case 2: case 1: case 2:
sym->stack.num = sym->stack.max = 1; if (!str_array_push(sym, dashed_null, -1, &sym->stack))
sym->stack.elts[0] = dashed_null; return FALSE;
break; break;
case 4: case 4:
sym->result = (char*)function_name; sym->result = (char*)function_name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment