com php-src: fix leak and error check order: ext/pgsql/pgsql.c

From: Date: Sat, 03 Sep 2016 14:59:17 +0000
Subject: com php-src: fix leak and error check order: ext/pgsql/pgsql.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94280@lists.php.net to get a copy of this message
Commit: 9513187deec82ffb2f56b86ce5f940d1fb5329f9 Author: Anatol Belski <ab@php.net> Sat, 3 Sep 2016 16:59:17 +0200 Parents: bca913d70a541b0f837aa1394c4c32d6d0d2ffa1 Branches: PHP-5.6 PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9513187deec82ffb2f56b86ce5f940d1fb5329f9 Log: fix leak and error check order Changed paths: M ext/pgsql/pgsql.c Diff: diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 8f3518d..f05efc7 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -4043,12 +4043,12 @@ 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 (!pg_delim) { + pg_delim = "\t"; + } if (!pg_null_as) { pg_null_as = safe_estrdup("\\\\N"); free_pg_null = 1; @@ -4176,6 +4176,9 @@ 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 (!pg_delim) { pg_delim = "\t"; } @@ -4184,8 +4187,6 @@ PHP_FUNCTION(pg_copy_from) pg_null_as_free = 1; } - ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); - spprintf(&query, 0, "COPY %s FROM STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, *pg_delim, pg_null_as); while ((pgsql_result = PQgetResult(pgsql))) { PQclear(pgsql_result);

« previous php.cvs (#94280) next »