]> granicus.if.org Git - php/commitdiff
MFB:
authorIlia Alshanetsky <iliaa@php.net>
Tue, 7 Oct 2008 14:35:04 +0000 (14:35 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 7 Oct 2008 14:35:04 +0000 (14:35 +0000)
 Fixed bug #46042 (memory leaks with reflection of mb_convert_encoding())
 Fixed bug #46110 (XMLWriter - openmemory() and openuri() leak memory on
  multiple calls).
 Fixed bug #46206 (pg_query_params/pg_execute convert passed values to
  strings).

NEWS
ext/openssl/xp_ssl.c
ext/pgsql/pgsql.c
ext/xmlwriter/php_xmlwriter.c

diff --git a/NEWS b/NEWS
index 53ff4c7fb0c2f0b5a4cf5efb852c6b4818e71ab3..d05761ae27512d2b920bfb6bdfc58637a0c7ca13 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,11 +20,15 @@ PHP                                                                        NEWS
   (Christian Seiler)
 - Fixed bug #46215 (json_encode mutates its parameter and has some 
   class-specific state). (Felipe)
+- Fixed bug #46206 (pg_query_params/pg_execute convert passed values to
+  strings). (Ilia)
 - Fixed bug #46191 (BC break: DOMDocument saveXML() doesn't accept null). (Rob)
 - Fixed bug #46164 (stream_filter_remove() closes the stream). (Arnaud)
 - Fixed bug #46157 (PDOStatement::fetchObject prototype error). (Felipe)
 - Fixed bug #46147 (after stream seek, appending stream filter reads 
   incorrect data). (Greg)
+- Fixed bug #46110 (XMLWriter - openmemory() and openuri() leak memory on
+  multiple calls). (Ilia)
 - Fixed bug #46088 (RegexIterator::accept - segfault). (Felipe)
 - Fixed bug #46059 (Compile failure under IRIX 6.5.30 building posix.c). 
   (Arnaud)
@@ -77,6 +81,7 @@ PHP                                                                        NEWS
 - Fixed bug #45405 (snmp extension memory leak). (Federico Cuello, Rodrigo
   Campos)
 - Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Arnaud)
+- Fixed bug #45382 (timeout bug in stream_socket_enable_crypto). (Ilia)
 - Fixed bug #45373 (php crash on query with errors in params). (Felipe)
 - Fixed bug #45352 (Segmentation fault because of tick function on second
   request). (Dmitry)
index e0d6e3c475782d02d70e31bdf8d7cb3f4edf55b7..557856cbc0c7939a353f67498b85306bd8316164 100644 (file)
@@ -417,7 +417,7 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
                                n = SSL_connect(sslsock->ssl_handle);
                                gettimeofday(&tve, &tz);
 
-                               timeout -= (tve.tv_sec + tve.tv_usec / 1000000) - (tvs.tv_sec + tvs.tv_usec / 1000000);
+                               timeout -= (tve.tv_sec + (float) tve.tv_usec / 1000000) - (tvs.tv_sec + (float) tvs.tv_usec / 1000000);
                                if (timeout < 0) {
                                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL: connection timeout");
                                        return -1;
index 8f4b0e6531dcd739519e537e87af3e1e886dd1c5..948dcc9634f89f37a115e9605ba72d24a1aad77f 100644 (file)
@@ -1199,6 +1199,10 @@ PHP_FUNCTION(pg_query)
 static void _php_pgsql_free_params(char **params, int num_params)
 {
        if (num_params > 0) {
+               int i;
+               for (i = 0; i < num_params; i++) {
+                       efree(params[i]);
+               }
                efree(params);
        }
 }
@@ -1216,7 +1220,6 @@ PHP_FUNCTION(pg_query_params)
        int leftover = 0;
        int num_params = 0;
        char **params = NULL;
-       unsigned char otype;
        PGconn *pgsql;
        PGresult *pgsql_result;
        ExecStatusType status;
@@ -1276,19 +1279,20 @@ PHP_FUNCTION(pg_query_params)
                                RETURN_FALSE;
                        }
 
-                       otype = (*tmp)->type;
-                       convert_to_string_ex(tmp);
-                       if (Z_TYPE_PP(tmp) != IS_STRING) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
-                               _php_pgsql_free_params(params, num_params);
-                               RETURN_FALSE;
-                       }
-
-                       if (otype == IS_NULL) {
+                       if (Z_TYPE_PP(tmp) == IS_NULL) {
                                params[i] = NULL;
-                       }
-                       else {
-                               params[i] = Z_STRVAL_PP(tmp);
+                       } else {
+                               zval tmp_val = **tmp;
+                               zval_copy_ctor(&tmp_val);
+                               convert_to_string(&tmp_val);
+                               if (Z_TYPE(tmp_val) != IS_STRING) {
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
+                                       zval_dtor(&tmp_val);
+                                       _php_pgsql_free_params(params, num_params);
+                                       RETURN_FALSE;
+                               }
+                               params[i] = estrndup(Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
+                               zval_dtor(&tmp_val);
                        }
 
                        zend_hash_move_forward(Z_ARRVAL_PP(pv_param_arr));
@@ -1439,7 +1443,6 @@ PHP_FUNCTION(pg_execute)
        int leftover = 0;
        int num_params = 0;
        char **params = NULL;
-       unsigned char otype;
        PGconn *pgsql;
        PGresult *pgsql_result;
        ExecStatusType status;
@@ -1500,19 +1503,20 @@ PHP_FUNCTION(pg_execute)
                                RETURN_FALSE;
                        }
 
-                       otype = (*tmp)->type;
-                       SEPARATE_ZVAL(tmp);
-                       convert_to_string_ex(tmp);
-                       if (Z_TYPE_PP(tmp) != IS_STRING) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
-                               _php_pgsql_free_params(params, num_params);
-                               RETURN_FALSE;
-                       }
-
-                       if (otype == IS_NULL) {
+                       if (Z_TYPE_PP(tmp) == IS_NULL) {
                                params[i] = NULL;
                        } else {
-                               params[i] = Z_STRVAL_PP(tmp);
+                               zval tmp_val = **tmp;
+                               zval_copy_ctor(&tmp_val);
+                               convert_to_string(&tmp_val);
+                               if (Z_TYPE(tmp_val) != IS_STRING) {
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
+                                       zval_dtor(&tmp_val);
+                                       _php_pgsql_free_params(params, num_params);
+                                       RETURN_FALSE;
+                               }
+                               params[i] = estrndup(Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
+                               zval_dtor(&tmp_val);
                        }
 
                        zend_hash_move_forward(Z_ARRVAL_PP(pv_param_arr));
@@ -4048,7 +4052,6 @@ PHP_FUNCTION(pg_send_query_params)
        zval **pv_param_arr, **tmp;
        int num_params = 0;
        char **params = NULL;
-       unsigned char otype;
        zval **query;
        int id = -1;
        PGconn *pgsql;
@@ -4097,20 +4100,20 @@ PHP_FUNCTION(pg_send_query_params)
                                RETURN_FALSE;
                        }
 
-                       otype = (*tmp)->type;
-                       SEPARATE_ZVAL(tmp);
-                       convert_to_string_ex(tmp);
-                       if (Z_TYPE_PP(tmp) != IS_STRING) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
-                               _php_pgsql_free_params(params, num_params);
-                               RETURN_FALSE;
-                       }
-
-                       if (otype == IS_NULL) {
+                       if (Z_TYPE_PP(tmp) == IS_NULL) {
                                params[i] = NULL;
-                       }
-                       else {
-                               params[i] = Z_STRVAL_PP(tmp);
+                       } else {
+                               zval tmp_val = **tmp;
+                               zval_copy_ctor(&tmp_val);
+                               convert_to_string(&tmp_val);
+                               if (Z_TYPE(tmp_val) != IS_STRING) {
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
+                                       zval_dtor(&tmp_val);
+                                       _php_pgsql_free_params(params, num_params);
+                                       RETURN_FALSE;
+                               }
+                               params[i] = estrndup(Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
+                               zval_dtor(&tmp_val);
                        }
 
                        zend_hash_move_forward(Z_ARRVAL_PP(pv_param_arr));
@@ -4194,7 +4197,6 @@ PHP_FUNCTION(pg_send_execute)
        zval **pv_param_arr, **tmp;
        int num_params = 0;
        char **params = NULL;
-       unsigned char otype;
        zval **stmtname;
        int id = -1;
        PGconn *pgsql;
@@ -4241,19 +4243,20 @@ PHP_FUNCTION(pg_send_execute)
                                RETURN_FALSE;
                        }
 
-                       otype = (*tmp)->type;
-                       convert_to_string(*tmp);
-                       if (Z_TYPE_PP(tmp) != IS_STRING) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
-                               _php_pgsql_free_params(params, num_params);
-                               RETURN_FALSE;
-                       }
-
-                       if (otype == IS_NULL) {
+                       if (Z_TYPE_PP(tmp) == IS_NULL) {
                                params[i] = NULL;
-                       }
-                       else {
-                               params[i] = Z_STRVAL_PP(tmp);
+                       } else {
+                               zval tmp_val = **tmp;
+                               zval_copy_ctor(&tmp_val);
+                               convert_to_string(&tmp_val);
+                               if (Z_TYPE(tmp_val) != IS_STRING) {
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
+                                       zval_dtor(&tmp_val);
+                                       _php_pgsql_free_params(params, num_params);
+                                       RETURN_FALSE;
+                               }
+                               params[i] = estrndup(Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
+                               zval_dtor(&tmp_val);
                        }
 
                        zend_hash_move_forward(Z_ARRVAL_PP(pv_param_arr));
index 29ec8ce1eb9ab3020c93955c116a7f7c8e70a68d..fbffcaece78601846a42e243ffee9df382c8c301 100644 (file)
@@ -1483,6 +1483,9 @@ static PHP_FUNCTION(xmlwriter_open_uri)
        intern->uri_output = out_buffer;
 #else
        if (this) {
+               if (ze_obj->xmlwriter_ptr) {
+                       xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr TSRMLS_CC);
+               }
                ze_obj->xmlwriter_ptr = intern;
                RETURN_TRUE;
        } else
@@ -1533,6 +1536,9 @@ static PHP_FUNCTION(xmlwriter_open_memory)
        intern->uri_output = NULL;
 #else
        if (this) {
+               if (ze_obj->xmlwriter_ptr) {
+                       xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr TSRMLS_CC);
+               }
                ze_obj->xmlwriter_ptr = intern;
                RETURN_TRUE;
        } else