summaryrefslogtreecommitdiff
path: root/ext/pgsql
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2016-09-03 17:04:43 +0200
committerAnatol Belski <ab@php.net>2016-09-03 17:04:43 +0200
commit1b2a06fe641252b0938ad2a7d4a25caf9b411a99 (patch)
tree117b08ccdad8f24486f1988a88ef4422795c61e2 /ext/pgsql
parent9eeb705ecad0d563ee85dac38164c035e47d0d84 (diff)
parentc9040d43a88d21a8cfe9329c2f97400919dfc283 (diff)
downloadphp-git-1b2a06fe641252b0938ad2a7d4a25caf9b411a99.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: fix leak and error check order
Diffstat (limited to 'ext/pgsql')
-rw-r--r--ext/pgsql/pgsql.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 4ae0ae63ea..1aa3855af0 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -4122,14 +4122,14 @@ 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";
- }
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 = estrdup("\\\\N");
free_pg_null = 1;
@@ -4255,6 +4255,11 @@ PHP_FUNCTION(pg_copy_from)
&pg_delim, &pg_delim_len, &pg_null_as, &pg_null_as_len) == FAILURE) {
return;
}
+
+ 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";
}
@@ -4263,10 +4268,6 @@ PHP_FUNCTION(pg_copy_from)
pg_null_as_free = 1;
}
- if ((pgsql = (PGconn *)zend_fetch_resource2(Z_RES_P(pgsql_link), "PostgreSQL link", le_link, le_plink)) == NULL) {
- RETURN_FALSE;
- }
-
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);