]> granicus.if.org Git - php/commitdiff
Fixed bug #29944 (Function defined in switch, crashes).
authorDmitry Stogov <dmitry@php.net>
Mon, 25 Apr 2005 09:58:06 +0000 (09:58 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 25 Apr 2005 09:58:06 +0000 (09:58 +0000)
NEWS
Zend/tests/bug29944.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index 9943097edcd1f5a6112eadc2f3cbaa136350f1e6..2a4024a8c68f677b655043038ac912bf08049b7d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,7 @@ PHP                                                                        NEWS
 - Fixed bug #31363 (broken non-blocking flock()). ian at snork dot net
 - Fixed bug #30833 (array_count_values() modifying input array). (Tony)
 - Fixed bug #30819 (Better support for LDAP SASL bind). (Jani)
+- Fixed bug #29944 (Function defined in switch, crashes). (Dmitry)
 - Fixed bug #29583 (crash when echoing a COM object). (M.Sisolak, Wez)
 - Fixed bug #28839 (SIGSEGV in interactive mode (php -a)).
   (kameshj at fastmail dot fm)
diff --git a/Zend/tests/bug29944.phpt b/Zend/tests/bug29944.phpt
new file mode 100644 (file)
index 0000000..6c0cf1e
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #29944 (Function defined in switch, crashes)
+--FILE--
+<?php
+$a = 1;
+switch ($a) {
+  case 1:
+    function foo($a) {
+      return "ok\n";
+    }
+    echo foo($a);
+}
+?>
+--EXPECT--
+ok
+
index 5053677bc2e9bc08ac23284a582c5f7bfd8b1c5e..72bcba6d8a70dd7366f156f0c1b0127fd712cb7c 100644 (file)
@@ -1455,7 +1455,7 @@ static int generate_free_switch_expr(zend_switch_entry *switch_entry TSRMLS_DC)
        zend_op *opline;
        
        if (switch_entry->cond.op_type != IS_VAR && switch_entry->cond.op_type != IS_TMP_VAR) {
-               return 0;
+               return (switch_entry->cond.op_type == IS_UNUSED);
        }
        
        opline = get_next_op(CG(active_op_array) TSRMLS_CC);