Skip to content

Commit cb7f133

Browse files
committed
Fix NULL pointer access
1 parent 56d920e commit cb7f133

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,10 @@ PHP_METHOD(PDOStatement, fetchAll)
13471347
ZSTR_VAL(get_active_function_or_method_name()), ZEND_NUM_ARGS());
13481348
RETURN_THROWS();
13491349
}
1350+
if (arg2 == NULL) {
1351+
zend_argument_type_error(2, "must be a callable, null given");
1352+
RETURN_THROWS();
1353+
}
13501354
/* TODO Check it is a callable? */
13511355
ZVAL_COPY_VALUE(&stmt->fetch.func.function, arg2);
13521356
if (do_fetch_func_prepare(stmt) == false) {

ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ object(PDOStatement)#%d (1) {
116116
["queryString"]=>
117117
string(21) "SELECT * FROM testing"
118118
}
119-
data: 2,
119+
data: 2,
120120
array(2) {
121121
[0]=>
122122
string(3) "PHP"
@@ -125,11 +125,8 @@ array(2) {
125125
}
126126
function "nothing" not found or invalid function name
127127
function "" not found or invalid function name
128+
PDOStatement::fetchAll(): Argument #2 ($arg2) must be a callable, null given
128129
no array or string given
129-
no array or string given
130-
131-
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
132-
bool(false)
133130
cannot access "self" when no class scope is active
134131
array(2) {
135132
[0]=>
@@ -145,4 +142,4 @@ array(2) {
145142
}
146143
non-static method bar::test2() cannot be called statically
147144
non-static method bar::test3() cannot be called statically
148-
class bar does not have a method "inexistent" in %s on line %d
145+
class bar does not have a method "inexistent"

0 commit comments

Comments
 (0)