Dan Hipschman : widl: Fix a crash in compare_expr.

Alexandre Julliard julliard at winehq.org
Thu Oct 25 08:38:47 CDT 2007


Module: wine
Branch: master
Commit: 9825ac7a1a0e2ac0088efe6ffda30000a9da2dfd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9825ac7a1a0e2ac0088efe6ffda30000a9da2dfd

Author: Dan Hipschman <dsh at linux.ucla.edu>
Date:   Wed Oct 24 18:06:16 2007 -0700

widl: Fix a crash in compare_expr.

---

 tools/widl/typegen.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 9dcffa7..f6d5536 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -228,6 +228,22 @@ static const char *get_context_handle_type_name(const type_t *type)
     return NULL;
 }
 
+/* This is actually fairly involved to implement precisely, due to the
+   effects attributes may have and things like that.  Right now this is
+   only used for optimization, so just check for a very small set of
+   criteria that guarantee the types are equivalent; assume every thing
+   else is different.   */
+static int compare_type(const type_t *a, const type_t *b)
+{
+    if (a == b
+        || (a->name
+            && b->name
+            && strcmp(a->name, b->name) == 0))
+        return 0;
+    /* Ordering doesn't need to be implemented yet.  */
+    return 1;
+}
+
 static int compare_expr(const expr_t *a, const expr_t *b)
 {
     int ret;
@@ -265,12 +281,17 @@ static int compare_expr(const expr_t *a, const expr_t *b)
             if (ret != 0)
                 return ret;
             return compare_expr(a->u.ext, b->u.ext);
+        case EXPR_CAST:
+            ret = compare_type(a->u.tref, b->u.tref);
+            if (ret != 0)
+                return ret;
+            /* Fall through.  */
         case EXPR_NOT:
         case EXPR_NEG:
         case EXPR_PPTR:
-        case EXPR_CAST:
-        case EXPR_SIZEOF:
             return compare_expr(a->ref, b->ref);
+        case EXPR_SIZEOF:
+            return compare_type(a->u.tref, b->u.tref);
         case EXPR_VOID:
             return 0;
     }




More information about the wine-cvs mailing list