[vala/0.48] codegen: Don't leak array memory after it was implicitly copied
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] codegen: Don't leak array memory after it was implicitly copied
- Date: Sun, 28 Feb 2021 17:26:26 +0000 (UTC)
commit 87aff2c4611e202bd1179d119106ae677ddb08dc
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Feb 2 10:34:54 2021 +0100
codegen: Don't leak array memory after it was implicitly copied
Found by -fsanitize=address
codegen/valaccodebasemodule.vala | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index f92764e35..88570b1d3 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -6121,6 +6121,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
Report.error (node.source_reference, "missing class prerequisite for
interface `%s', add GLib.Object to interface declaration if unsure".printf
(target_type.type_symbol.get_full_name ()));
return result;
}
+ // need to free old array after copying it
+ if (array_needs_copy && requires_destroy (type)) {
+ result.value_type = type.copy ();
+ ccode.add_expression (destroy_value (result));
+ }
result = copy;
// implicit array copying is deprecated, but allow it for internal codegen usage
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]