From: Rico Tzschichholz Date: Wed, 3 Feb 2021 12:40:23 +0000 (+0100) Subject: codegen: Don't leak GLib.Value when implicitly unboxing it X-Git-Tag: 0.51.1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5328619a8141aa11341d479428ebfdcec0ff9756;p=thirdparty%2Fvala.git codegen: Don't leak GLib.Value when implicitly unboxing it Found by -fsanitize=address --- diff --git a/codegen/valagvaluemodule.vala b/codegen/valagvaluemodule.vala index 0429085e6..f13022c26 100644 --- a/codegen/valagvaluemodule.vala +++ b/codegen/valagvaluemodule.vala @@ -44,6 +44,17 @@ public class Vala.GValueModule : GAsyncModule { } ccall.add_argument (gvalue); + if (value_type.is_disposable ()) { + var temp_var = get_temp_variable (value_type, true, expr, false); + emit_temp_var (temp_var); + var temp_ref = get_variable_cexpression (temp_var.name); + ccode.add_assignment (temp_ref, get_cvalue (expr.inner)); + + // value needs to be kept alive until the end of this block + assert (current_symbol is Block); + ((Block) current_symbol).add_local_variable (temp_var); + } + CCodeExpression rv; if (target_type is ArrayType) { var temp_var = get_temp_variable (target_type, true, expr, false);