summaryrefslogtreecommitdiff
path: root/ext/pgsql
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-04-20 14:11:53 +0000
committerFelipe Pena <felipe@php.net>2010-04-20 14:11:53 +0000
commit5aedea717917628b93ebf9f5f767dd5d17f898b3 (patch)
treefdab36388d2b3870487e9ac94e07451ca3679089 /ext/pgsql
parenta175419f8405701ee18cbd85fa30a026c3c41df9 (diff)
downloadphp-git-5aedea717917628b93ebf9f5f767dd5d17f898b3.tar.gz
- Fixed bug #51609 (pg_copy_to: Invalid results when using fourth parameter)
Diffstat (limited to 'ext/pgsql')
-rw-r--r--ext/pgsql/pgsql.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 92725ee996..5fbfd5870e 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -3735,7 +3735,7 @@ PHP_FUNCTION(pg_copy_to)
{
zval *pgsql_link;
char *table_name, *pg_delim = NULL, *pg_null_as = NULL;
- int table_name_len, pg_delim_len, pg_null_as_len;
+ int table_name_len, pg_delim_len, pg_null_as_len, free_pg_null = 0;
char *query;
int id = -1;
PGconn *pgsql;
@@ -3762,6 +3762,7 @@ PHP_FUNCTION(pg_copy_to)
if (!pg_null_as) {
pg_null_as = safe_estrdup("\\\\N");
+ free_pg_null = 1;
}
if (memchr(table_name, '.', table_name_len)) {
@@ -3774,7 +3775,9 @@ PHP_FUNCTION(pg_copy_to)
PQclear(pgsql_result);
}
pgsql_result = PQexec(pgsql, query);
- efree(pg_null_as);
+ if (free_pg_null) {
+ efree(pg_null_as);
+ }
efree(query);
if (pgsql_result) {