From 5d3cf577aad15b119c137a873f468c0614f2eb2e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 11 Jun 2015 19:41:43 +0200 Subject: Make convert_to_* safe with rc>1 This only involves switching zval_dtor to zval_ptr_dtor for arrays and making the convert_to_object for arrays a bit more generic. All the other changes outside zend_operators.c just make use of this new ability (use COPY instead of DUP). What's still missing: Proper references handling. I've seen many convert_to* calls that will break when a reference is used. Also fixes bug #69788. --- ext/pgsql/pgsql.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/pgsql/pgsql.c') diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index a65b7a0aa9..6965589154 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -4246,7 +4246,7 @@ PHP_FUNCTION(pg_copy_from) #if HAVE_PQPUTCOPYDATA ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pg_rows), value) { zval tmp; - ZVAL_DUP(&tmp, value); + ZVAL_COPY(&tmp, value); convert_to_string_ex(&tmp); query = (char *)emalloc(Z_STRLEN(tmp) + 2); strlcpy(query, Z_STRVAL(tmp), Z_STRLEN(tmp) + 2); @@ -4270,7 +4270,7 @@ PHP_FUNCTION(pg_copy_from) #else ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pg_rows), value) { zval tmp; - ZVAL_DUP(&tmp, value); + ZVAL_COPY(&tmp, value); convert_to_string_ex(&tmp); query = (char *)emalloc(Z_STRLEN(tmp) + 2); strlcpy(query, Z_STRVAL(tmp), Z_STRLEN(tmp) + 2); -- cgit v1.2.1