andrey          Fri Sep 19 11:35:37 2008 UTC

  Added files:                 
    /php-src/ext/mysqli/tests   bug46109.phpt 

  Modified files:              
    /php-src/ext/mysqli mysqli.c mysqli_api.c 
  Log:
  Fix for bug#46019 MySQLi::init() leaks memory
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli.c?r1=1.133&r2=1.134&diff_format=u
Index: php-src/ext/mysqli/mysqli.c
diff -u php-src/ext/mysqli/mysqli.c:1.133 php-src/ext/mysqli/mysqli.c:1.134
--- php-src/ext/mysqli/mysqli.c:1.133   Mon Sep 15 18:07:58 2008
+++ php-src/ext/mysqli/mysqli.c Fri Sep 19 11:35:37 2008
@@ -17,7 +17,7 @@
   |          Ulf Wendel <[EMAIL PROTECTED]>                                    
 |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli.c,v 1.133 2008/09/15 18:07:58 andrey Exp $ 
+  $Id: mysqli.c,v 1.134 2008/09/19 11:35:37 andrey Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -1255,7 +1255,7 @@
                        } else {
                                ZVAL_STRINGL(res, row[i], field_len[i], 1);     
                        }
-
+                       if (m
                        if (fetchtype & MYSQLI_NUM) {
                                add_index_zval(return_value, i, res);
                        }
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli_api.c?r1=1.168&r2=1.169&diff_format=u
Index: php-src/ext/mysqli/mysqli_api.c
diff -u php-src/ext/mysqli/mysqli_api.c:1.168 
php-src/ext/mysqli/mysqli_api.c:1.169
--- php-src/ext/mysqli/mysqli_api.c:1.168       Sat Aug  2 04:40:44 2008
+++ php-src/ext/mysqli/mysqli_api.c     Fri Sep 19 11:35:37 2008
@@ -17,7 +17,7 @@
   |          Ulf Wendel <[EMAIL PROTECTED]>                                    
 |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_api.c,v 1.168 2008/08/02 04:40:44 felipe Exp $ 
+  $Id: mysqli_api.c,v 1.169 2008/09/19 11:35:37 andrey Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -1364,7 +1364,13 @@
 PHP_FUNCTION(mysqli_init)
 {
        MYSQLI_RESOURCE *mysqli_resource;
-       MY_MYSQL *mysql = (MY_MYSQL *)ecalloc(1, sizeof(MY_MYSQL));
+       MY_MYSQL *mysql;
+
+       if (getThis() && instanceof_function(Z_OBJCE_P(getThis()), 
mysqli_link_class_entry TSRMLS_CC)) {
+               return;
+       }
+
+       mysql = (MY_MYSQL *)ecalloc(1, sizeof(MY_MYSQL));
 
 #if !defined(MYSQLI_USE_MYSQLND)
        if (!(mysql->mysql = mysql_init(NULL)))

http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/bug46109.phpt?view=markup&rev=1.1
Index: php-src/ext/mysqli/tests/bug46109.phpt
+++ php-src/ext/mysqli/tests/bug46109.phpt
--TEST--
Bug #46109 (MySQLi::init - Memory leaks)
--SKIPIF--
<?php 
require_once('skipif.inc'); 
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
        include "connect.inc";

        $mysqli = new mysqli();
        $mysqli->init();
        $mysqli->init();
        echo "done";    
?>
--EXPECTF--
done



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to