tony2001                Tue Apr 10 09:37:09 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/standard/tests/general_functions       bug41037.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/standard       basic_functions.c 
  Log:
  MFH: fix #41037 (unregister_tick_function() inside the tick function crash 
PHP)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.632&r2=1.2027.2.547.2.633&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.632 php-src/NEWS:1.2027.2.547.2.633
--- php-src/NEWS:1.2027.2.547.2.632     Mon Apr  9 16:35:10 2007
+++ php-src/NEWS        Tue Apr 10 09:37:09 2007
@@ -47,6 +47,8 @@
 - Fixed zend_llist_remove_tail (Michael Wallner, Dmitry)
 - Fixed a thread safety issue in gd gif read code (Nuno, Roman Nemecek)
 - Fixed CVE-2007-1001, GD wbmp used with invalid image size (Pierre)
+- Fixed bug #41037 (unregister_tick_function() inside the tick function crash 
PHP).
+  (Tony)
 - Fixed bug #41026 (segfault when calling "self::method()" in shutdown 
functions).
   (Tony)
 - Fixed bug #40999 (mcrypt_create_iv() not using random seed). (Ilia)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.31.2.47&r2=1.725.2.31.2.48&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.31.2.47 
php-src/ext/standard/basic_functions.c:1.725.2.31.2.48
--- php-src/ext/standard/basic_functions.c:1.725.2.31.2.47      Sat Mar 10 
19:20:16 2007
+++ php-src/ext/standard/basic_functions.c      Tue Apr 10 09:37:09 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.725.2.31.2.47 2007/03/10 19:20:16 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.725.2.31.2.48 2007/04/10 09:37:09 tony2001 Exp $ 
*/
 
 #include "php.h"
 #include "php_streams.h"
@@ -5317,17 +5317,24 @@
 {
        zval *func1 = tick_fe1->arguments[0];
        zval *func2 = tick_fe2->arguments[0];
+       int ret;
        TSRMLS_FETCH();
 
        if (Z_TYPE_P(func1) == IS_STRING && Z_TYPE_P(func2) == IS_STRING) {
-               return (zend_binary_zval_strcmp(func1, func2) == 0);
+               ret = (zend_binary_zval_strcmp(func1, func2) == 0);
        } else if (Z_TYPE_P(func1) == IS_ARRAY && Z_TYPE_P(func2) == IS_ARRAY) {
                zval result;
                zend_compare_arrays(&result, func1, func2 TSRMLS_CC);
-               return (Z_LVAL(result) == 0);
+               ret = (Z_LVAL(result) == 0);
        } else {
+               ret = 0;
+       }
+
+       if (ret && tick_fe1->calling) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to delete 
tick function executed at the moment");
                return 0;
        }
+       return ret;
 }
 
 void php_call_shutdown_functions(TSRMLS_D)

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/bug41037.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/general_functions/bug41037.phpt
+++ php-src/ext/standard/tests/general_functions/bug41037.phpt
--TEST--
Bug #41037 (unregister_tick_function() inside the tick function crash PHP)
--FILE--
<?php

function a() {
                echo "hello";
                        unregister_tick_function('a');
}

declare (ticks=1);
register_tick_function('a');

echo "Done\n";
?>
--EXPECTF--     
hello
Warning: unregister_tick_function(): Unable to delete tick function executed at 
the moment in %s on line %d
Done
hello
Warning: unregister_tick_function(): Unable to delete tick function executed at 
the moment in %s on line %d
hello
Warning: unregister_tick_function(): Unable to delete tick function executed at 
the moment in %s on line %d

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to