[vala/staging: 4/4] codegen: Don't leak GLib.Value when implicitly unboxing it
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 4/4] codegen: Don't leak GLib.Value when implicitly unboxing it
- Date: Wed, 3 Feb 2021 13:10:22 +0000 (UTC)
commit 3e3c80f2cb066c2ff21d3890e6dd53f82f003239
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Feb 3 13:40:23 2021 +0100
codegen: Don't leak GLib.Value when implicitly unboxing it
Found by -fsanitize=address
codegen/valagvaluemodule.vala | 11 +++++++++++
1 file changed, 11 insertions(+)
---
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]