]> granicus.if.org Git - php/commitdiff
fix #41037 (unregister_tick_function() inside the tick function crash PHP)
authorAntony Dovgal <tony2001@php.net>
Tue, 10 Apr 2007 09:36:10 +0000 (09:36 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 10 Apr 2007 09:36:10 +0000 (09:36 +0000)
ext/standard/basic_functions.c
ext/standard/tests/general_functions/bug41037.phpt [new file with mode: 0644]

index 8c76d408fff293754e52ddad4814bbe7b429c23c..efc39d03dc97cb0106db74c501c2fc2cfcc62253 100644 (file)
@@ -5239,19 +5239,26 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_
 {
        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_UNICODE && Z_TYPE_P(func2) == IS_UNICODE) {
-               return (zend_u_binary_zval_strcmp(func1, func2) == 0);
+               ret = (zend_u_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)
diff --git a/ext/standard/tests/general_functions/bug41037.phpt b/ext/standard/tests/general_functions/bug41037.phpt
new file mode 100644 (file)
index 0000000..eab2c33
--- /dev/null
@@ -0,0 +1,23 @@
+--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