[svn:parrot] r49009 - trunk/src/call

luben at svn.parrot.org luben at svn.parrot.org
Wed Sep 15 01:08:50 UTC 2010


Author: luben
Date: Wed Sep 15 01:08:50 2010
New Revision: 49009
URL: https://trac.parrot.org/parrot/changeset/49009

Log:
fix using a hash after it is freed

Modified:
   trunk/src/call/args.c

Modified: trunk/src/call/args.c
==============================================================================
--- trunk/src/call/args.c	Wed Sep 15 01:07:22 2010	(r49008)
+++ trunk/src/call/args.c	Wed Sep 15 01:08:50 2010	(r49009)
@@ -1135,8 +1135,6 @@
         ++param_index;
     }
 
-    if (named_used_list != NULL)
-        parrot_hash_destroy(interp, named_used_list);
 
     /* Double check that all named arguments were assigned to parameters. */
     if (err_check) {
@@ -1145,6 +1143,8 @@
         /* Early exit to avoid vtable call */
         GETATTR_CallContext_hash(interp, call_object, h);
         if (!h || !h->entries){
+            if (named_used_list != NULL)
+                parrot_hash_destroy(interp, named_used_list);
             return;
         }
 
@@ -1153,7 +1153,10 @@
         if (!PMC_IS_NULL(named_arg_list)) {
             const INTVAL named_arg_count = VTABLE_elements(interp, named_arg_list);
 
-            if (named_used_list==NULL)
+            if (named_used_list==NULL){
+                if (named_used_list != NULL)
+                    parrot_hash_destroy(interp, named_used_list);
+
                 return;
 
                 /* The 'return' above is a temporary hack to duplicate an old
@@ -1165,6 +1168,7 @@
                     "too many named arguments: %d passed, 0 used",
                     named_arg_count);
                  */
+            }
 
             if (named_arg_count > named_count) {
                 /* At this point we know we have named arguments that weren't
@@ -1179,6 +1183,8 @@
                             named_arg_list, named_arg_index);
 
                     if (!parrot_hash_exists(interp, named_used_list, name)) {
+                        if (named_used_list != NULL)
+                            parrot_hash_destroy(interp, named_used_list);
                         Parrot_ex_throw_from_c_args(interp, NULL,
                                 EXCEPTION_INVALID_OPERATION,
                                 "too many named arguments: '%S' not used",
@@ -1188,6 +1194,8 @@
             }
         }
     }
+    if (named_used_list != NULL)
+        parrot_hash_destroy(interp, named_used_list);
 }
 
 


More information about the parrot-commits mailing list