mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
fix leak in pg_copy_to() when invalid resource was passed
This commit is contained in:
parent
7d7f84562c
commit
37635d93e6
1 changed files with 3 additions and 2 deletions
|
@ -3309,12 +3309,13 @@ PHP_FUNCTION(pg_copy_to)
|
|||
if (!pg_delim) {
|
||||
pg_delim = "\t";
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
if (!pg_null_as) {
|
||||
pg_null_as = safe_estrdup("\\\\N");
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
query = (char *)emalloc(strlen(query_template) + strlen(table_name) + strlen(pg_null_as) + 1);
|
||||
sprintf(query, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'",
|
||||
table_name, *pg_delim, pg_null_as);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue