[PATCH 2/2] [Msvcrt]: in undname functions, no longer use a fixed-size array for storing internal information

Eric Pouech eric.pouech at orange.fr
Sun Nov 15 15:07:44 CST 2009


(fix for #20681)

A+
---

 0 files changed, 0 insertions(+), 0 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 at T@@QAEHQCY1BE at BO@D at Z", "public: int __thiscall T::f(char (volatile * const)[20][30])"},
 /* 112 */ {"?f at T@@QAEHQAY2BE at BO@CI at D@Z", "public: int __thiscall T::f(char (* const)[20][30][40])"},
 /* 113 */ {"?f at T@@QAEHQAY1BE at BO@$$CBD at Z", "public: int __thiscall T::f(char const (* const)[20][30])"},
+/* 114 */ {"??0?$Foo at U?$vector_c at H$00$01$0?1$0A@$0A@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@@mpl at boost@@@@QAE at 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;






More information about the wine-patches mailing list