Skip to content

Commit 4927242

Browse files
committed
pgsqlSetNoticeCallback: accept closure callbacks
Fix to what @ranvis noted in php#4823 (comment)
1 parent 3050a2f commit 4927242

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static int pdo_pgsql_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *in
144144
static void pdo_pgsql_cleanup_notice_callback(pdo_pgsql_db_handle *H) /* {{{ */
145145
{
146146
if (H->notice_callback) {
147+
zval_ptr_dtor(&H->notice_callback->fci.function_name);
147148
efree(H->notice_callback);
148149
H->notice_callback = NULL;
149150
}
@@ -1169,6 +1170,7 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback)
11691170
if (!(fc = H->notice_callback)) {
11701171
fc = (pdo_pgsql_fci*)ecalloc(1, sizeof(pdo_pgsql_fci));
11711172
} else {
1173+
zval_ptr_dtor(&fc->fci.function_name);
11721174
memcpy(&fc->fcc, &empty_fcall_info_cache, sizeof(fc->fcc));
11731175
}
11741176

@@ -1179,6 +1181,7 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback)
11791181
H->notice_callback = NULL;
11801182
RETURN_FALSE;
11811183
}
1184+
Z_ADDREF_P(&fc->fci.function_name);
11821185
zend_string_release_ex(cbname, 0);
11831186

11841187
H->notice_callback = fc;

0 commit comments

Comments
 (0)