Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 9881582

Browse files
committed
Fix leaks when not cleaning up after compiling function in context with args and/or context exts
1 parent 1800be1 commit 9881582

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/php_v8_script_compiler.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ static PHP_METHOD(V8ScriptCompiler, CompileFunctionInContext)
236236
static_cast<size_t>(context_extensions_count),
237237
context_extensions);
238238

239+
if (arguments) {
240+
efree(arguments);
241+
}
242+
243+
if (context_extensions) {
244+
efree(context_extensions);
245+
}
246+
239247
PHP_V8_MAYBE_CATCH(php_v8_context, try_catch);
240248
PHP_V8_THROW_VALUE_EXCEPTION_WHEN_EMPTY(maybe_function, "Failed to compile function in context");
241249

src/php_v8_source.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void php_v8_update_source_cached_data(zval *src_zv, v8::ScriptCompiler::Source *
3939
php_v8_create_cached_data(&tmp, source->GetCachedData());
4040

4141
zend_update_property(this_ce, src_zv, ZEND_STRL("cached_data"), &tmp);
42+
Z_DELREF(tmp);
4243
}
4344

4445
static PHP_METHOD(V8Source, __construct)

0 commit comments

Comments
 (0)