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

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 e1c2637b5218d198de77184ea43814f2a6887fe2..41c0104979eacc0e50d59fbb2c418646c49afe9a 100644 (file)
@@ -1530,7 +1530,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);