From: Anatol Belski Date: Sat, 3 Sep 2016 15:03:55 +0000 (+0200) Subject: Merge branch 'PHP-5.6' into PHP-7.0 X-Git-Tag: php-7.1.0RC2~56^2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9040d43a88d21a8cfe9329c2f97400919dfc283;p=php Merge branch 'PHP-5.6' into PHP-7.0 * PHP-5.6: fix leak and error check order --- c9040d43a88d21a8cfe9329c2f97400919dfc283 diff --cc ext/pgsql/pgsql.c index 8f0db26c92,f05efc7939..9ee81b1ac5 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@@ -4083,16 -4043,14 +4083,16 @@@ PHP_FUNCTION(pg_copy_to &pg_delim, &pg_delim_len, &pg_null_as, &pg_null_as_len) == FAILURE) { return; } - if (!pg_delim) { - pg_delim = "\t"; - } - ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); + if ((pgsql = (PGconn *)zend_fetch_resource2(Z_RES_P(pgsql_link), "PostgreSQL link", le_link, le_plink)) == NULL) { + RETURN_FALSE; + } + if (!pg_delim) { + pg_delim = "\t"; + } if (!pg_null_as) { - pg_null_as = safe_estrdup("\\\\N"); + pg_null_as = estrdup("\\\\N"); free_pg_null = 1; } @@@ -4216,6 -4176,9 +4216,11 @@@ PHP_FUNCTION(pg_copy_from &pg_delim, &pg_delim_len, &pg_null_as, &pg_null_as_len) == FAILURE) { return; } + - ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); ++ if ((pgsql = (PGconn *)zend_fetch_resource2(Z_RES_P(pgsql_link), "PostgreSQL link", le_link, le_plink)) == NULL) { ++ RETURN_FALSE; ++ } + if (!pg_delim) { pg_delim = "\t"; }