[vala/0.50] 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/0.50] codegen: Don't leak GLib.Value when implicitly unboxing it
- Date: Sun, 28 Feb 2021 08:58:22 +0000 (UTC)
commit c9c1ce8f8d38c965d024fc25df68847d46ae0e7e
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 | 10 ++++++++++
1 file changed, 10 insertions(+)
---
diff --git a/codegen/valagvaluemodule.vala b/codegen/valagvaluemodule.vala
index a6109fd40..607a8f867 100644
--- a/codegen/valagvaluemodule.vala
+++ b/codegen/valagvaluemodule.vala
@@ -44,6 +44,16 @@ 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
+ temp_ref_values.insert (0, get_local_cvalue (temp_var));
+ }
+
CCodeExpression rv = ccall;
if (expr != null && target_type is ArrayType) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]