iliaa           Mon Oct 17 10:30:36 2005 EDT

  Modified files:              (Branch: PHP_5_1)
    /php-src    NEWS 
    /php-src/ext/sqlite sqlite.c 
  Log:
  MFH: Fixed bug #34884 (Possible crash in ext/sqlite when sqlite.assoc_case 
  is being used).
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.132&r2=1.2027.2.133&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.132 php-src/NEWS:1.2027.2.133
--- php-src/NEWS:1.2027.2.132   Mon Oct 17 03:56:55 2005
+++ php-src/NEWS        Mon Oct 17 10:30:33 2005
@@ -2,6 +2,8 @@
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Oct 2005, PHP 5.1 Release Candidate 3
 - Fixed bug #34873 (Segmentation Fault on foreach in object). (Dmitry)
+- Fixed bug #34884 (Possible crash in ext/sqlite when sqlite.assoc_case is 
+  being used). (Tony,Ilia)
 
 14 Oct 2005, PHP 5.1 Release Candidate 2
 - Changed SQLite extension to be a shared module in Windows distribution.
http://cvs.php.net/diff.php/php-src/ext/sqlite/sqlite.c?r1=1.166.2.1&r2=1.166.2.2&ty=u
Index: php-src/ext/sqlite/sqlite.c
diff -u php-src/ext/sqlite/sqlite.c:1.166.2.1 
php-src/ext/sqlite/sqlite.c:1.166.2.2
--- php-src/ext/sqlite/sqlite.c:1.166.2.1       Thu Sep  8 17:07:40 2005
+++ php-src/ext/sqlite/sqlite.c Mon Oct 17 10:30:35 2005
@@ -17,7 +17,7 @@
    |          Marcus Boerger <[EMAIL PROTECTED]>                              |
    +----------------------------------------------------------------------+
 
-   $Id: sqlite.c,v 1.166.2.1 2005/09/08 21:07:40 iliaa Exp $ 
+   $Id: sqlite.c,v 1.166.2.2 2005/10/17 14:30:35 iliaa Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -1125,7 +1125,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "SQLite support", "enabled");
-       php_info_print_table_row(2, "PECL Module version", 
PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.166.2.1 2005/09/08 21:07:40 iliaa 
Exp $");
+       php_info_print_table_row(2, "PECL Module version", 
PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.166.2.2 2005/10/17 14:30:35 iliaa 
Exp $");
        php_info_print_table_row(2, "SQLite Library", sqlite_libversion());
        php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding());
        php_info_print_table_end();
@@ -1440,14 +1440,13 @@
                /* first row - lets copy the column names */
                rres->col_names = safe_emalloc(rres->ncolumns, sizeof(char *), 
0);
                for (i = 0; i < rres->ncolumns; i++) {
-                       colname = (char*)colnames[i];
+                       rres->col_names[i] = estrdup((char*)colnames[i]);
 
                        if (SQLITE_G(assoc_case) == 1) {
-                               php_sqlite_strtoupper(colname);
+                               php_sqlite_strtoupper(rres->col_names[i]);
                        } else if (SQLITE_G(assoc_case) == 2) {
-                               php_sqlite_strtolower(colname);
+                               php_sqlite_strtolower(rres->col_names[i]);
                        }
-                       rres->col_names[i] = estrdup(colname);
                }
                if (!rres->buffered) {
                        /* non buffered mode - also fetch memory for on single 
row */
@@ -1686,16 +1685,17 @@
        array_init(return_value);
 
        for (i = 0; i < ncols; i++) {
-               char *colname = (char *)colnames[i];
+               if (result_type == PHPSQLITE_ASSOC) {
+                       char *colname = estrdup((char *)colnames[i]);
 
-               if (SQLITE_G(assoc_case) == 1) {
-                       php_sqlite_strtoupper(colname);
-               } else if (SQLITE_G(assoc_case) == 2) {
-                       php_sqlite_strtolower(colname);
-               }
+                       if (SQLITE_G(assoc_case) == 1) {
+                               php_sqlite_strtoupper(colname);
+                       } else if (SQLITE_G(assoc_case) == 2) {
+                               php_sqlite_strtolower(colname);
+                       }
 
-               if (result_type == PHPSQLITE_ASSOC) {
                        add_assoc_string(return_value, colname, colnames[ncols 
+ i] ? (char *)colnames[ncols + i] : "", 1);
+                       efree(colname);
                }
                if (result_type == PHPSQLITE_NUM) {
                        add_index_string(return_value, i, colnames[ncols + i] ? 
(char *)colnames[ncols + i] : "", 1);

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

Reply via email to