Skip to content

Commit 9be00e3

Browse files
committed
Ensure driver specific PDO methods have a proper run_time_cache
1 parent da9db14 commit 9be00e3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ext/pdo/pdo_dbh.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "zend_hash.h"
3535
#include "pdo_dbh_arginfo.h"
3636
#include "zend_observer.h"
37+
#include "zend_extensions.h"
3738

3839
static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value);
3940

@@ -1204,6 +1205,9 @@ static void cls_method_dtor(zval *el) /* {{{ */ {
12041205
if (func->common.function_name) {
12051206
zend_string_release_ex(func->common.function_name, 0);
12061207
}
1208+
if (ZEND_MAP_PTR(func->common.run_time_cache)) {
1209+
efree(ZEND_MAP_PTR(func->common.run_time_cache));
1210+
}
12071211
efree(func);
12081212
}
12091213
/* }}} */
@@ -1213,6 +1217,9 @@ static void cls_method_pdtor(zval *el) /* {{{ */ {
12131217
if (func->common.function_name) {
12141218
zend_string_release_ex(func->common.function_name, 1);
12151219
}
1220+
if (ZEND_MAP_PTR(func->common.run_time_cache)) {
1221+
pefree(ZEND_MAP_PTR(func->common.run_time_cache), 1);
1222+
}
12161223
pefree(func, 1);
12171224
}
12181225
/* }}} */
@@ -1240,13 +1247,14 @@ bool pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind)
12401247

12411248
memset(&func, 0, sizeof(func));
12421249

1250+
size_t rt_cache_size = zend_internal_run_time_cache_reserved_size();
12431251
while (funcs->fname) {
12441252
func.type = ZEND_INTERNAL_FUNCTION;
12451253
func.handler = funcs->handler;
12461254
func.function_name = zend_string_init(funcs->fname, strlen(funcs->fname), dbh->is_persistent);
12471255
func.scope = dbh_obj->std.ce;
12481256
func.prototype = NULL;
1249-
ZEND_MAP_PTR(func.run_time_cache) = NULL;
1257+
ZEND_MAP_PTR(func.run_time_cache) = rt_cache_size ? pemalloc(rt_cache_size, dbh->is_persistent) : NULL;
12501258
func.T = ZEND_OBSERVER_ENABLED;
12511259
if (funcs->flags) {
12521260
func.fn_flags = funcs->flags | ZEND_ACC_NEVER_CACHE;

0 commit comments

Comments
 (0)