]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 17 Sep 2019 11:15:01 +0000 (13:15 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 17 Sep 2019 11:15:01 +0000 (13:15 +0200)
1  2 
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/standard/array.c

index d2ff9757c7daf1a5f3ef1695d5b2c90ecf418d81,2d8fe24fbc082bd0da7df3f5f3994c64fa1f14b0..ccd46c575d2280e701a0a09db85b697aee2b6f94
@@@ -8593,13 -8601,15 +8593,17 @@@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_CO
                        count = zend_array_count(Z_ARRVAL_P(op1));
                        break;
                } else if (Z_TYPE_P(op1) == IS_OBJECT) {
 +                      zend_object *zobj = Z_OBJ_P(op1);
 +
                        /* first, we check if the handler is defined */
 -                      if (Z_OBJ_HT_P(op1)->count_elements) {
 -                              if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) {
 +                      if (zobj->handlers->count_elements) {
 +                              if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
                                        break;
                                }
+                               if (UNEXPECTED(EG(exception))) {
+                                       count = 0;
+                                       break;
+                               }
                        }
  
                        /* if not and the object implements Countable we call its count() method */
index 1bd056f73fdc1d0183d99324936f2763f48b68ef,5927f7958017823cdc538f0b328b4728a4fbb3e0..1a62480bb3f1e77224814cd79077a3487dcae725
@@@ -9553,13 -9629,15 +9553,17 @@@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER
                        count = zend_array_count(Z_ARRVAL_P(op1));
                        break;
                } else if (Z_TYPE_P(op1) == IS_OBJECT) {
 +                      zend_object *zobj = Z_OBJ_P(op1);
 +
                        /* first, we check if the handler is defined */
 -                      if (Z_OBJ_HT_P(op1)->count_elements) {
 -                              if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) {
 +                      if (zobj->handlers->count_elements) {
 +                              if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
                                        break;
                                }
+                               if (UNEXPECTED(EG(exception))) {
+                                       count = 0;
+                                       break;
+                               }
                        }
  
                        /* if not and the object implements Countable we call its count() method */
@@@ -16682,13 -16770,15 +16686,17 @@@ static ZEND_OPCODE_HANDLER_RET ZEND_FAS
                        count = zend_array_count(Z_ARRVAL_P(op1));
                        break;
                } else if (Z_TYPE_P(op1) == IS_OBJECT) {
 +                      zend_object *zobj = Z_OBJ_P(op1);
 +
                        /* first, we check if the handler is defined */
 -                      if (Z_OBJ_HT_P(op1)->count_elements) {
 -                              if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) {
 +                      if (zobj->handlers->count_elements) {
 +                              if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
                                        break;
                                }
+                               if (UNEXPECTED(EG(exception))) {
+                                       count = 0;
+                                       break;
+                               }
                        }
  
                        /* if not and the object implements Countable we call its count() method */
@@@ -47308,13 -46643,15 +47316,17 @@@ static ZEND_OPCODE_HANDLER_RET ZEND_FAS
                        count = zend_array_count(Z_ARRVAL_P(op1));
                        break;
                } else if (Z_TYPE_P(op1) == IS_OBJECT) {
 +                      zend_object *zobj = Z_OBJ_P(op1);
 +
                        /* first, we check if the handler is defined */
 -                      if (Z_OBJ_HT_P(op1)->count_elements) {
 -                              if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) {
 +                      if (zobj->handlers->count_elements) {
 +                              if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) {
                                        break;
                                }
+                               if (UNEXPECTED(EG(exception))) {
+                                       count = 0;
+                                       break;
+                               }
                        }
  
                        /* if not and the object implements Countable we call its count() method */
index 245eeba7d876b6d38da60ffae2d261e067134dc2,d44e5d50e741b6ac61bfffa3641f226365e8940c..6634611f5e25c822c7bee63b17b80fd9a233c5f2
@@@ -789,9 -791,12 +789,12 @@@ PHP_FUNCTION(count
                        /* first, we check if the handler is defined */
                        if (Z_OBJ_HT_P(array)->count_elements) {
                                RETVAL_LONG(1);
 -                              if (SUCCESS == Z_OBJ_HT(*array)->count_elements(array, &Z_LVAL_P(return_value))) {
 +                              if (SUCCESS == Z_OBJ_HT(*array)->count_elements(Z_OBJ_P(array), &Z_LVAL_P(return_value))) {
                                        return;
                                }
+                               if (EG(exception)) {
+                                       return;
+                               }
                        }
                        /* if not and the object implements Countable we call its count() method */
                        if (instanceof_function(Z_OBJCE_P(array), zend_ce_countable)) {