]> granicus.if.org Git - php/commitdiff
- Fixed bug #46546 (Segmentation fault when using declare statement with non-string...
authorFelipe Pena <felipe@php.net>
Tue, 11 Nov 2008 16:15:53 +0000 (16:15 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 11 Nov 2008 16:15:53 +0000 (16:15 +0000)
# This issue only happens in this branch

Zend/tests/declare_001.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/declare_001.phpt b/Zend/tests/declare_001.phpt
new file mode 100644 (file)
index 0000000..8f6f733
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Testing declare statement with several type values
+--FILE--
+<?php
+
+declare(encoding = 1);
+declare(encoding = 1123131232131312321);
+declare(encoding = NULL);
+declare(encoding = M_PI);
+declare(encoding = 'utf-8');
+
+print 'DONE';
+
+?>
+--EXPECT--
+DONE
index 5d1c583fb1842ca02538fcd9113e696b3c0e66ff..90dcad362eb76d59a3acb80d81e6b23c02719284 100644 (file)
@@ -4770,12 +4770,13 @@ void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC)
                                zend_multibyte_yyinput_again(old_input_filter, old_encoding TSRMLS_CC);
                        }
                }
+               efree(val->u.constant.value.str.val);
 #else  /* !ZEND_MULTIBYTE */
        } else if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) {
                /* Do not generate any kind of warning for encoding declares */
                /* zend_error(E_COMPILE_WARNING, "Declare encoding [%s] not supported", val->u.constant.value.str.val); */
+               zval_dtor(&val->u.constant);
 #endif /* ZEND_MULTIBYTE */
-               efree(val->u.constant.value.str.val);
        } else {
                zend_error(E_COMPILE_WARNING, "Unsupported declare '%s'", var->u.constant.value.str.val);
                zval_dtor(&val->u.constant);