diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-02-03 13:40:23 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-02-03 14:29:12 +0100 |
commit | 5328619a8141aa11341d479428ebfdcec0ff9756 (patch) | |
tree | acb007a63c3c824c7f3644f8daf0277d74420b4a /codegen/valagvaluemodule.vala | |
parent | 4d023541e4b013a05d55a258044b6a20e6fb7e01 (diff) | |
download | vala-5328619a8141aa11341d479428ebfdcec0ff9756.tar.gz |
codegen: Don't leak GLib.Value when implicitly unboxing it
Found by -fsanitize=address
Diffstat (limited to 'codegen/valagvaluemodule.vala')
-rw-r--r-- | codegen/valagvaluemodule.vala | 11 |
1 files changed, 11 insertions, 0 deletions
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); |