[vala] Fix memory leak of method arguments in error case
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Fix memory leak of method arguments in error case
- Date: Thu, 11 Mar 2010 23:19:45 +0000 (UTC)
commit e4635d0c209591c1daf7ececf3593fe11be22f59
Author: Jürg Billeter <j bitron ch>
Date: Fri Mar 12 00:07:08 2010 +0100
Fix memory leak of method arguments in error case
Fixes bug 611242.
codegen/valaccodebasemodule.vala | 30 ++++++++++++------------------
1 files changed, 12 insertions(+), 18 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 99f7d54..e1b6bdb 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3065,26 +3065,15 @@ internal class Vala.CCodeBaseModule : CCodeModule {
stmt.ccodenode = new CCodeExpressionStatement ((CCodeExpression) stmt.expression.ccodenode);
- if (stmt.tree_can_fail && stmt.expression.tree_can_fail) {
- // simple case, no node breakdown necessary
-
- var cfrag = new CCodeFragment ();
-
- cfrag.append (stmt.ccodenode);
-
- head.add_simple_check (stmt.expression, cfrag);
-
- stmt.ccodenode = cfrag;
- }
-
- /* free temporary objects */
+ /* free temporary objects and handle errors */
if (((List<LocalVariable>) temp_vars).size == 0
- && pre_statement_fragment == null) {
- /* nothing to do without temporary variables */
+ && pre_statement_fragment == null
+ && (!stmt.tree_can_fail || !stmt.expression.tree_can_fail)) {
+ /* nothing to do without temporary variables and errors */
return;
}
-
+
var cfrag = new CCodeFragment ();
append_temp_decl (cfrag, temp_vars);
@@ -3101,9 +3090,14 @@ internal class Vala.CCodeBaseModule : CCodeModule {
ma.value_type = local.variable_type.copy ();
cfrag.append (new CCodeExpressionStatement (get_unref_expression (get_variable_cexpression (local.name), local.variable_type, ma)));
}
-
+
+ if (stmt.tree_can_fail && stmt.expression.tree_can_fail) {
+ // simple case, no node breakdown necessary
+ head.add_simple_check (stmt.expression, cfrag);
+ }
+
stmt.ccodenode = cfrag;
-
+
temp_vars.clear ();
temp_ref_vars.clear ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]