summaryrefslogtreecommitdiff
path: root/ext/sqlite3/sqlite3.c
diff options
context:
space:
mode:
authorScott MacVicar <scottmac@php.net>2008-09-15 00:55:37 +0000
committerScott MacVicar <scottmac@php.net>2008-09-15 00:55:37 +0000
commit8b912cc49c9bcfeb75281226c49bea43f34bb441 (patch)
treef844bbac554020cac2137355cafd2c47808b984f /ext/sqlite3/sqlite3.c
parent6c7f41d4829267481d8f1ad64b8a534c91151389 (diff)
downloadphp-git-8b912cc49c9bcfeb75281226c49bea43f34bb441.tar.gz
Fixed bug #46033 (Segfault when instantiating SQLite3Stmt and SQLite3Result)
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r--ext/sqlite3/sqlite3.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 9015356580..d7e9d0a765 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -1626,7 +1626,9 @@ static void php_sqlite3_stmt_object_free_storage(void *object TSRMLS_DC) /* {{{
(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);
@@ -1641,15 +1643,17 @@ static void php_sqlite3_result_object_free_storage(void *object TSRMLS_DC) /* {{
return;
}
- if (intern->stmt_obj->initialised) {
- sqlite3_reset(intern->stmt_obj->stmt);
- }
+ 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);
+ 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);
@@ -1690,6 +1694,8 @@ static zend_object_value php_sqlite3_stmt_object_new(zend_class_entry *class_typ
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 *));
@@ -1712,6 +1718,7 @@ static zend_object_value php_sqlite3_result_object_new(zend_class_entry *class_t
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 *));