Fix double free
authorCharles <char101@ui.ac.id>
Fri, 21 Sep 2012 09:42:13 +0000 (16:42 +0700)
committerCharles <char101@ui.ac.id>
Fri, 21 Sep 2012 09:42:13 +0000 (16:42 +0700)
ext/twig/twig.c

index a1b9d0e..4476bb7 100644 (file)
@@ -927,11 +927,10 @@ PHP_FUNCTION(twig_template_get_attributes)
                        return;
                }
 
-               efree(tmp_method_name_get);
-               efree(tmp_method_name_is);
-               efree(lcItem);
-
                if (isDefinedTest) {
+                       efree(tmp_method_name_get);
+                       efree(tmp_method_name_is);
+                       efree(lcItem);
                        RETURN_TRUE;
                }
 /*
@@ -943,6 +942,9 @@ PHP_FUNCTION(twig_template_get_attributes)
                        TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getExtension", "sandbox" TSRMLS_CC), "checkMethodAllowed", object, &zitem TSRMLS_CC);
                }
                if (EG(exception)) {
+                       efree(tmp_method_name_get);
+                       efree(tmp_method_name_is);
+                       efree(lcItem);
                        return;
                }
 /*