mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-16 20:28:04 +01:00
Fix memory leak for compiler constants
The ownership for constants is not transfered to the new function so the constant buffer must be cleared when the compiler is finished.
This commit is contained in:
@ -1280,6 +1280,7 @@ static void freeCompiler(Compiler* compiler)
|
||||
{
|
||||
wrenByteBufferClear(compiler->parser->vm, &compiler->bytecode);
|
||||
wrenIntBufferClear(compiler->parser->vm, &compiler->debugSourceLines);
|
||||
wrenValueBufferClear(compiler->parser->vm, &compiler->constants);
|
||||
}
|
||||
|
||||
// Finishes [compiler], which is compiling a function, method, or chunk of top
|
||||
@ -1317,6 +1318,9 @@ static ObjFn* endCompiler(Compiler* compiler,
|
||||
compiler->debugSourceLines.data);
|
||||
wrenPushRoot(compiler->parser->vm, (Obj*)fn);
|
||||
|
||||
// Clear constants. The constants are copied by wrenNewFunction
|
||||
wrenValueBufferClear(compiler->parser->vm, &compiler->constants);
|
||||
|
||||
// In the function that contains this one, load the resulting function object.
|
||||
if (compiler->parent != NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user