[vala/0.50] codegen: Don't leak memory moving heap-allocated struct to stack
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.50] codegen: Don't leak memory moving heap-allocated struct to stack
- Date: Sun, 28 Feb 2021 08:58:22 +0000 (UTC)
commit f85be6f78d31f02ea84fb93fe9cf9822bbf07513
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Feb 3 23:16:41 2021 +0100
codegen: Don't leak memory moving heap-allocated struct to stack
Found by -fsanitize=address
codegen/valaccodebasemodule.vala | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 5aee4d5c6..c2127094d 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5397,6 +5397,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var innercexpr = get_cvalue (expr.inner);
if (expr.type_reference is ValueType && !expr.type_reference.nullable &&
expr.inner.value_type is ValueType && expr.inner.value_type.nullable) {
+ if (!(expr.inner.symbol_reference is Variable)) {
+ // heap allocated struct leaked, destroy it
+ var value = new GLibValue (new PointerType (new VoidType ()), innercexpr);
+ temp_ref_values.insert (0, value);
+ }
// nullable integer or float or boolean or struct or enum cast to non-nullable
innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION,
innercexpr);
} else if (expr.type_reference is ValueType && expr.type_reference.nullable &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]