cvs: php-src /ext/sqlite3 sqlite3.c
| From: | Scott MacVicar | Date: | Mon, 15 Sep 2008 01:00:52 +0000 |
| Subject: | cvs: php-src /ext/sqlite3 sqlite3.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-53146@lists.php.net to get a copy of this message | ||
scottmac Mon Sep 15 01:00:52 2008 UTC
Modified files:
/php-src/ext/sqlite3 sqlite3.c
Log:
MFB Fixed bug #46033 (Segfault when instantiating SQLite3Stmt and SQLite3Result)
http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.12&r2=1.13&diff_format=u
Index: php-src/ext/sqlite3/sqlite3.c
diff -u php-src/ext/sqlite3/sqlite3.c:1.12 php-src/ext/sqlite3/sqlite3.c:1.13
--- php-src/ext/sqlite3/sqlite3.c:1.12 Tue Aug 12 13:32:30 2008
+++ php-src/ext/sqlite3/sqlite3.c Mon Sep 15 01:00:52 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sqlite3.c,v 1.12 2008/08/12 13:32:30 felipe Exp $ */
+/* $Id: sqlite3.c,v 1.13 2008/09/15 01:00:52 scottmac Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1652,7 +1652,9 @@
(int (*)(void *, void *)) php_sqlite3_compare_stmt_free);
}
- Z_DELREF_P(intern->db_obj_zval);
+ if (intern->db_obj_zval) {
+ Z_DELREF_P(intern->db_obj_zval);
+ }
zend_object_std_dtor(&intern->zo TSRMLS_CC);
efree(intern);
@@ -1666,16 +1668,17 @@
if (!intern) {
return;
}
-
- if (intern->stmt_obj->initialised) {
- sqlite3_reset(intern->stmt_obj->stmt);
- }
-
- if (intern->is_prepared_statement == 0) {
- zval_dtor(intern->stmt_obj_zval);
- FREE_ZVAL(intern->stmt_obj_zval);
- } else {
- zval_ptr_dtor(&intern->stmt_obj_zval);
+ if (intern->stmt_obj_zval) {
+ if (intern->stmt_obj->initialised) {
+ sqlite3_reset(intern->stmt_obj->stmt);
+ }
+
+ if (intern->is_prepared_statement == 0) {
+ zval_dtor(intern->stmt_obj_zval);
+ FREE_ZVAL(intern->stmt_obj_zval);
+ } else {
+ zval_ptr_dtor(&intern->stmt_obj_zval);
+ }
}
zend_object_std_dtor(&intern->zo TSRMLS_CC);
@@ -1716,6 +1719,8 @@
intern = emalloc(sizeof(php_sqlite3_stmt));
memset(&intern->zo, 0, sizeof(php_sqlite3_stmt));
+ intern->db_obj_zval = NULL;
+
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
zend_hash_copy(intern->zo.properties, &class_type->default_properties,
(copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *));
@@ -1738,6 +1743,7 @@
intern->complete = 0;
intern->is_prepared_statement = 0;
+ intern->stmt_obj_zval = NULL;
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
zend_hash_copy(intern->zo.properties, &class_type->default_properties,
(copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *));