]> granicus.if.org Git - php/commitdiff
MF51: prevent segfault when exception is thrown from Countable::count()
authorAntony Dovgal <tony2001@php.net>
Wed, 22 Mar 2006 22:06:08 +0000 (22:06 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 22 Mar 2006 22:06:08 +0000 (22:06 +0000)
ext/standard/array.c

index af64947fdd23ad0445b17f89e92a02fa537bac37..3ae61a4973723eaeb30f8f8a0cb485b6c3d42413 100644 (file)
@@ -318,8 +318,10 @@ PHP_FUNCTION(count)
 
                        if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) {
                                zend_call_method_with_0_params(&array, NULL, NULL, "count", &retval);
-                               RETVAL_LONG(Z_LVAL_P(retval));
-                               zval_ptr_dtor(&retval);
+                               if (retval) {
+                                       RETVAL_LONG(Z_LVAL_P(retval));
+                                       zval_ptr_dtor(&retval);
+                               }
                                return;
                        }
 #endif