@@ -638,7 +638,7 @@ PHP_METHOD(PDO, prepare)
638638 if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 )) != NULL ) {
639639 if (Z_TYPE_P (item ) != IS_ARRAY ) {
640640 zend_type_error ("PDO::ATTR_STATEMENT_CLASS constructor_args must be of type ?array, %s given" ,
641- zend_zval_value_name (value ));
641+ zend_zval_value_name (item ));
642642 RETURN_THROWS ();
643643 }
644644 ZVAL_COPY_VALUE (& ctor_args , item );
@@ -931,17 +931,18 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value, u
931931 zend_argument_type_error (value_arg_num , "User-supplied statement class cannot have a public constructor" );
932932 return false;
933933 }
934+ item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 );
935+ if (item != NULL && Z_TYPE_P (item ) != IS_ARRAY ) {
936+ zend_argument_type_error (value_arg_num , "PDO::ATTR_STATEMENT_CLASS constructor_args must be of type ?array, %s given" ,
937+ zend_zval_value_name (item ));
938+ return false;
939+ }
934940 dbh -> def_stmt_ce = pce ;
935941 if (!Z_ISUNDEF (dbh -> def_stmt_ctor_args )) {
936942 zval_ptr_dtor (& dbh -> def_stmt_ctor_args );
937943 ZVAL_UNDEF (& dbh -> def_stmt_ctor_args );
938944 }
939- if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 )) != NULL ) {
940- if (Z_TYPE_P (item ) != IS_ARRAY ) {
941- zend_argument_type_error (value_arg_num , "PDO::ATTR_STATEMENT_CLASS constructor_args must be of type ?array, %s given" ,
942- zend_zval_value_name (value ));
943- return false;
944- }
945+ if (item != NULL ) {
945946 ZVAL_COPY (& dbh -> def_stmt_ctor_args , item );
946947 }
947948 return true;
0 commit comments