[PATCH] widl: Limit recursion deepth within structs to 1 for checking for full-pointers.

Kai Tietz ktietz70 at googlemail.com
Fri Aug 30 15:23:09 CDT 2013


2013/8/30 Kai Tietz <ktietz70 at googlemail.com>:
> Hello,
>
> attached patch limits recursion in type_has_full_pointer-function to a
> deeth of 1.  By this all necessary checks should be possible, but
> endless-recursion due diamond/cycle type-declarations are avoided.
> I was finding this issue by working on propidl.idl rework, and hit
> such an endless recursion.
>
> Regards,
> Kai

Sorry, attached wrong file (vim is your friend :/ ).

Kai
-------------- next part --------------
From 112297b139d66aa97f1c477d041f9da55819044c Mon Sep 17 00:00:00 2001
From: Kai Tietz <ktietz70 at googlemail.com>
Date: Fri, 30 Aug 2013 21:50:39 +0200
Subject: [PATCH] widl: Limit recursion deepth within structs to 1 for
 checking for full-pointers.

---
 tools/widl/typegen.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 0886d13..29ec15f 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -747,6 +747,7 @@ static int type_has_pointers(const type_t *type)
 static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs,
                                  int toplevel_param)
 {
+redo:
     switch (typegen_detect_type(type, NULL, TDT_IGNORE_STRINGS))
     {
     case TGT_USER_TYPE:
@@ -759,15 +760,18 @@ static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs,
     case TGT_ARRAY:
         if (get_pointer_fc(type, attrs, toplevel_param) == RPC_FC_FP)
             return TRUE;
-        else
-            return type_has_full_pointer(type_array_get_element(type), NULL, FALSE);
+	type = type_array_get_element(type);
+	attrs = NULL;
+	toplevel_param = 0;
+	goto redo;
+
     case TGT_STRUCT:
     {
         var_list_t *fields = type_struct_get_fields(type);
         const var_t *field;
-        if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
+        if (fields && toplevel_param) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
         {
-            if (type_has_full_pointer(field->type, field->attrs, FALSE))
+            if (field->type && type_has_full_pointer(field->type, field->attrs, FALSE))
                 return TRUE;
         }
         break;
@@ -777,7 +781,7 @@ static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs,
         var_list_t *fields;
         const var_t *field;
         fields = type_union_get_cases(type);
-        if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
+        if (fields && toplevel_param) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
         {
             if (field->type && type_has_full_pointer(field->type, field->attrs, FALSE))
                 return TRUE;
-- 
1.7.9


More information about the wine-patches mailing list