cvs: ZendEngine2 / zend_execute_API.c /tests bug47320.phpt php-src/main main.c
[email protected] ("Dmitry Stogov") Mon, 09 Feb 2009 09:20:46 -0000
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvsdmitry1234171246@cvsserver> |
dmitry Mon Feb 9 09:20:46 2009 UTC
Modified files:
/php-src/main main.c
/ZendEngine2 zend_execute_API.c
/ZendEngine2/tests bug47320.phpt
Log:
Fixed bug #47320 ($php_errormsg out of scope in functions)
http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.792&r2=1.793&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.792 php-src/main/main.c:1.793
--- php-src/main/main.c:1.792 Mon Jan 19 02:25:58 2009
+++ php-src/main/main.c Mon Feb 9 09:20:46 2009
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.792 2009/01/19 02:25:58 pajoye Exp $ */
+/* $Id: main.c,v 1.793 2009/02/09 09:20:46 dmitry Exp $ */
/* {{{ includes
*/
@@ -853,12 +853,17 @@
php_error(type, "%s", message);
efree(message);
- if (PG(track_errors) && module_initialized && EG(active_symbol_table) &&
+ if (PG(track_errors) && module_initialized &&
(!EG(user_error_handler) || !(EG(user_error_handler_error_reporting) & type))) {
- zval *tmp;
- ALLOC_INIT_ZVAL(tmp);
- ZVAL_RT_STRINGL(tmp, buffer, buffer_len, 1);
- zend_ascii_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) &tmp, sizeof(zval *), NULL);
+ if (!EG(active_symbol_table)) {
+ zend_rebuild_symbol_table(TSRMLS_C);
+ }
+ if (EG(active_symbol_table)) {
+ zval *tmp;
+ ALLOC_INIT_ZVAL(tmp);
+ ZVAL_RT_STRINGL(tmp, buffer, buffer_len, 1);
+ zend_ascii_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) &tmp, sizeof(zval *), NULL);
+ }
}
efree(buffer);
}
@@ -1125,12 +1130,17 @@
efree(buffer);
return;
}
- if (PG(track_errors) && module_initialized && EG(active_symbol_table)) {
- zval *tmp;
-
- ALLOC_INIT_ZVAL(tmp);
- ZVAL_RT_STRINGL(tmp, buffer, buffer_len, 1);
- zend_ascii_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(zval *), NULL);
+ if (PG(track_errors) && module_initialized) {
+ if (!EG(active_symbol_table)) {
+ zend_rebuild_symbol_table(TSRMLS_C);
+ }
+ if (EG(active_symbol_table)) {
+ zval *tmp;
+
+ ALLOC_INIT_ZVAL(tmp);
+ ZVAL_RT_STRINGL(tmp, buffer, buffer_len, 1);
+ zend_ascii_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(zval *), NULL);
+ }
}
efree(buffer);
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.471&r2=1.472&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.471 ZendEngine2/zend_execute_API.c:1.472
--- ZendEngine2/zend_execute_API.c:1.471 Fri Jan 2 13:14:17 2009
+++ ZendEngine2/zend_execute_API.c Mon Feb 9 09:20:46 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute_API.c,v 1.471 2009/01/02 13:14:17 helly Exp $ */
+/* $Id: zend_execute_API.c,v 1.472 2009/02/09 09:20:46 dmitry Exp $ */
#include <stdio.h>
#include <signal.h>
@@ -1785,15 +1785,15 @@
return;
}
- if (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
- /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/
- EG(active_symbol_table) = *(EG(symtable_cache_ptr)--);
- } else {
- ALLOC_HASHTABLE(EG(active_symbol_table));
- zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
- /*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/
- }
if (ex && ex->op_array) {
+ if (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
+ /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/
+ EG(active_symbol_table) = *(EG(symtable_cache_ptr)--);
+ } else {
+ ALLOC_HASHTABLE(EG(active_symbol_table));
+ zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
+ /*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/
+ }
ex->symbol_table = EG(active_symbol_table);
if (ex->op_array->this_var != -1 &&
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug47320.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug47320.phpt
diff -u /dev/null ZendEngine2/tests/bug47320.phpt:1.2
--- /dev/null Mon Feb 9 09:20:46 2009
+++ ZendEngine2/tests/bug47320.phpt Mon Feb 9 09:20:46 2009
@@ -0,0 +1,26 @@
+--TEST--
+Bug #47320 ($php_errormsg out of scope in functions)
+--INI--
+display_errors=0
+track_errors=1
+--FILE--
+<?php
+if (!@substr('no 2nd parameter')) {
+ echo '$php_errormsg in global: ' . $php_errormsg . "\n";
+}
+
+function foo() {
+ if (!@strpos('no 2nd parameter')) {
+ echo '$php_errormsg in function: ' . $php_errormsg . "\n";
+
+ echo '$GLOBALS[php_errormsg] in function: ' .
+ $GLOBALS['php_errormsg'] . "\n";
+ }
+}
+
+foo();
+?>
+--EXPECT--
+$php_errormsg in global: substr() expects at least 2 parameters, 1 given
+$php_errormsg in function: strpos() expects at least 2 parameters, 1 given
+$GLOBALS[php_errormsg] in function: substr() expects at least 2 parameters, 1 given