]> granicus.if.org Git - php/commitdiff
- Fixed memory corruption in pg_copy_from() in case the as_null parameter was
authorDerick Rethans <derick@php.net>
Tue, 5 Jul 2005 12:45:39 +0000 (12:45 +0000)
committerDerick Rethans <derick@php.net>
Tue, 5 Jul 2005 12:45:39 +0000 (12:45 +0000)
  passed. (Derick)

NEWS
ext/pgsql/pgsql.c

diff --git a/NEWS b/NEWS
index 472b64e2fd751d2adde96970799a9203be0e02f3..1acd0ffa1b09d40ffedf3e4a82ff768d68169c04 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index 2fa3657b25f04d8d6eb54456e6aafb128f82b3ae..ec863185e8b0fde3744ab8cdb3e66c03155eb471 100644 (file)
@@ -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) {