johannes                Thu Jun 25 09:38:04 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/sqlite/tests   bug48679.phpt 

  Modified files:              
    /php-src/ext/sqlite sqlite.c 
  Log:
  MFH Fix bug #48679 - Crash in SQLite with count on an unbuffered query set 
(Scott)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite/sqlite.c?r1=1.166.2.13.2.9.2.21&r2=1.166.2.13.2.9.2.22&diff_format=u
Index: php-src/ext/sqlite/sqlite.c
diff -u php-src/ext/sqlite/sqlite.c:1.166.2.13.2.9.2.21 
php-src/ext/sqlite/sqlite.c:1.166.2.13.2.9.2.22
--- php-src/ext/sqlite/sqlite.c:1.166.2.13.2.9.2.21     Sun Mar 22 15:05:20 2009
+++ php-src/ext/sqlite/sqlite.c Thu Jun 25 09:38:04 2009
@@ -17,7 +17,7 @@
    |          Marcus Boerger <he...@php.net>                              |
    +----------------------------------------------------------------------+
 
-   $Id: sqlite.c,v 1.166.2.13.2.9.2.21 2009/03/22 15:05:20 iliaa Exp $
+   $Id: sqlite.c,v 1.166.2.13.2.9.2.22 2009/06/25 09:38:04 johannes Exp $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -1458,7 +1458,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.13.2.9.2.21 2009/03/22 
15:05:20 iliaa Exp $");
+       php_info_print_table_row(2, "PECL Module version", 
PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.166.2.13.2.9.2.22 2009/06/25 
09:38:04 johannes 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();
@@ -2819,6 +2819,11 @@
 {
        sqlite_object *obj = (sqlite_object*) 
zend_object_store_get_object(object TSRMLS_CC);
 
+       if (obj->u.res == NULL) {
+               zend_throw_exception(sqlite_ce_exception, "Row count is not 
available for this query", 0 TSRMLS_CC);
+               return FAILURE;
+       }
+
        if (obj->u.res->buffered) {
                * count = obj->u.res->nrows;
                return SUCCESS;

http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite/tests/bug48679.phpt?view=markup&rev=1.1
Index: php-src/ext/sqlite/tests/bug48679.phpt
+++ php-src/ext/sqlite/tests/bug48679.phpt
--TEST--
Bug #48679 (sqlite2 count on unbuffered query causes segfault)
--SKIPIF--
<?php 
if (!extension_loaded("sqlite")) print "skip"; 
?>
--FILE--
<?php

try {
        $x = new sqliteunbuffered;
        count($x);
} catch (SQLiteException $e) {
        var_dump($e->getMessage());
}
echo "Done\n";
?>
--EXPECT--      
unicode(41) "Row count is not available for this query"
Done



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

Reply via email to