summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2010-05-26 07:28:43 +0000
committerAndrey Hristov <andrey@php.net>2010-05-26 07:28:43 +0000
commitce682f1b269c90f8c9a8ae37c394ea6b96c893a5 (patch)
treea46c330efaa07f37418e9eedccdb656a5359bd1b /ext/mysqli/mysqli.c
parent89e93723fb11a623a42518d5de2c6f5e51243fda (diff)
downloadphp-git-ce682f1b269c90f8c9a8ae37c394ea6b96c893a5.tar.gz
Add checks to check the underlying pointer in the resource.
It can happen that the underlying pointer is freed (like in the case of connection reconnect), and then it cannot be allocated anymore, which means that NULL will be used consequently by the functions that fetch the resource and the crash is immediate.
Diffstat (limited to 'ext/mysqli/mysqli.c')
-rw-r--r--ext/mysqli/mysqli.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 66b1f6f7d9..65c43c3499 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -984,7 +984,7 @@ PHP_FUNCTION(mysqli_stmt_construct)
if (zend_parse_parameters(1 TSRMLS_CC, "O", &mysql_link, mysqli_link_class_entry)==FAILURE) {
return;
}
- MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
+ MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
@@ -994,7 +994,7 @@ PHP_FUNCTION(mysqli_stmt_construct)
if (zend_parse_parameters(2 TSRMLS_CC, "Os", &mysql_link, mysqli_link_class_entry, &statement, &statement_len)==FAILURE) {
return;
}
- MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
+ MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
@@ -1048,7 +1048,7 @@ PHP_FUNCTION(mysqli_result_construct)
WRONG_PARAM_COUNT;
}
- MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
+ MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
switch (resmode) {
case MYSQLI_STORE_RESULT: