Skip to content

Commit e4a3732

Browse files
committed
no need to call zend_is_callable() if callable is known to be invalid
free fname on failure and plug possible leak
1 parent a400d89 commit e4a3732

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
703703

704704
static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * fci, zend_fcall_info_cache * fcc, int num_args TSRMLS_DC) /* {{{ */
705705
{
706-
zval **object = NULL, **method;
707-
char *fname, *cname;
706+
zval **object = NULL, **method = NULL;
707+
char *fname = NULL, *cname;
708708
zend_class_entry * ce = NULL, **pce;
709709
zend_function *function_handler;
710710

@@ -739,8 +739,11 @@ static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info *
739739
method = &callable;
740740
}
741741

742-
if (!zend_is_callable(callable, 0, &fname)) {
742+
if (!method || !zend_is_callable(callable, 0, &fname)) {
743743
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback" TSRMLS_CC);
744+
if (fname) {
745+
efree(fname);
746+
}
744747
return 0;
745748
}
746749

0 commit comments

Comments
 (0)