diff options
| author | Derick Rethans <derick@php.net> | 2005-07-05 12:45:39 +0000 |
|---|---|---|
| committer | Derick Rethans <derick@php.net> | 2005-07-05 12:45:39 +0000 |
| commit | 17b877a77242dfcfc6436340b8a9d804a60bf2c7 (patch) | |
| tree | ecb23d27f6a8ba03da95846aee815770ed7aa45a | |
| parent | d9248ab10eea50698d6aa36316f177c9f9db2d5e (diff) | |
| download | php-git-17b877a77242dfcfc6436340b8a9d804a60bf2c7.tar.gz | |
- Fixed memory corruption in pg_copy_from() in case the as_null parameter was
passed. (Derick)
| -rw-r--r-- | NEWS | 2 | ||||
| -rw-r--r-- | ext/pgsql/pgsql.c | 6 |
2 files changed, 7 insertions, 1 deletions
@@ -6,6 +6,8 @@ PHP NEWS - Added date_timezone_set() function to set the timezone that the date functions will use. (Derick) - Implemented feature request #33452 (Year belonging to ISO week). (Derick) +- Fixed memory corruption in pg_copy_from() in case the as_null parameter was + passed. (Derick) - Fixed bug #33562 (date("") crashes). (Derick) - Fixed bug #33536 (strtotime() defaults to now even on non time string). (Derick) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 2fa3657b25..ec863185e8 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -3280,6 +3280,7 @@ PHP_FUNCTION(pg_copy_from) zval **tmp; char *table_name, *pg_delim = NULL, *pg_null_as = NULL; int table_name_len, pg_delim_len, pg_null_as_len; + int pg_null_as_free = 0; char *query; char *query_template = "COPY \"\" FROM STDIN DELIMITERS ':' WITH NULL AS ''"; HashPosition pos; @@ -3299,6 +3300,7 @@ PHP_FUNCTION(pg_copy_from) } if (!pg_null_as) { pg_null_as = safe_estrdup("\\\\N"); + pg_null_as_free = 1; } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); @@ -3311,7 +3313,9 @@ PHP_FUNCTION(pg_copy_from) } pgsql_result = PQexec(pgsql, query); - efree(pg_null_as); + if (pg_null_as_free) { + efree(pg_null_as); + } efree(query); if (pgsql_result) { |
