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

index 03f6bfaafd3fcd1a845296d07a9ba4c9ca0016cb..6cc929ba4b4b201f84ad933dbec6da4e2e3d3e4f 100644 (file)
@@ -312,8 +312,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