@@ -88,7 +88,7 @@ static bool php_phongo_manager_merge_context_options(zval *zdriverOptions TSRMLS
8888
8989 /* Perform array union (see: add_function() in zend_operators.c) */
9090#if PHP_VERSION_ID >= 70000
91- zend_hash_merge (Z_ARRVAL_P (zdriverOptions ), Z_ARRVAL_P (zcontextOptions ), zval_add_ref , 0 );
91+ zend_hash_merge (Z_ARRVAL_P (zdriverOptions ), Z_ARRVAL_P (zcontextOptions ), zval_add_ref , 0 );
9292#else
9393 {
9494 zval * tmp ;
@@ -129,6 +129,8 @@ static void php_phongo_manager_prep_tagsets(zval *options TSRMLS_DC)
129129 /* php_phongo_make_uri() and php_phongo_apply_rp_options_to_uri()
130130 * are both case-insensitive, so we need to be as well. */
131131 if (!strcasecmp (ZSTR_VAL (string_key ), "readpreferencetags" )) {
132+ ZVAL_DEREF (tagSets );
133+ SEPARATE_ZVAL_NOREF (tagSets );
132134 php_phongo_read_preference_prep_tagsets (tagSets TSRMLS_CC );
133135 }
134136 } ZEND_HASH_FOREACH_END ();
@@ -152,6 +154,7 @@ static void php_phongo_manager_prep_tagsets(zval *options TSRMLS_DC)
152154 /* php_phongo_make_uri() and php_phongo_apply_rp_options_to_uri()
153155 * are both case-insensitive, so we need to be as well. */
154156 if (!strcasecmp (string_key , "readpreferencetags" )) {
157+ SEPARATE_ZVAL_IF_NOT_REF (tagSets );
155158 php_phongo_read_preference_prep_tagsets (* tagSets TSRMLS_CC );
156159 }
157160 }
@@ -177,9 +180,10 @@ PHP_METHOD(Manager, __construct)
177180 zend_replace_error_handling (EH_THROW , phongo_exception_from_phongo_domain (PHONGO_ERROR_INVALID_ARGUMENT ), & error_handling TSRMLS_CC );
178181 intern = Z_MANAGER_OBJ_P (getThis ());
179182
180- /* Separate the driverOptions zval, since we may end up modifying it in
181- * php_phongo_manager_merge_context_options() below. */
182- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|s!a!a!" , & uri_string , & uri_string_len , & options , & driverOptions ) == FAILURE ) {
183+ /* Separate the options and driverOptions zvals, since we may end up
184+ * modifying them in php_phongo_manager_prep_tagsets() and
185+ * php_phongo_manager_merge_context_options() below, respectively. */
186+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|s!a/!a/!" , & uri_string , & uri_string_len , & options , & driverOptions ) == FAILURE ) {
183187 zend_restore_error_handling (& error_handling TSRMLS_CC );
184188 return ;
185189 }
0 commit comments