[vala/emit-let: 1/4] codegen: Guard access to array length of TargetValue
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/emit-let: 1/4] codegen: Guard access to array length of TargetValue
- Date: Wed, 19 Jan 2011 23:38:07 +0000 (UTC)
commit 74902bfb8ed75f5df508c612140ef1436ac08583
Author: Luca Bruno <lucabru src gnome org>
Date: Thu Jan 20 00:31:41 2011 +0100
codegen: Guard access to array length of TargetValue
codegen/valaccodebasemodule.vala | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 00b1f40..8c72aa7 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2886,7 +2886,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccall.add_argument (new CCodeConstant ("TRUE"));
} else if (type is ArrayType) {
var array_type = (ArrayType) type;
- if (requires_destroy (array_type.element_type)) {
+ if (requires_destroy (array_type.element_type) && has_array_length (value)) {
CCodeExpression csizeexpr = null;
bool first = true;
for (int dim = 1; dim <= array_type.rank; dim++) {
@@ -4329,7 +4329,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue (expr.inner)));
var array_type = expr.value_type as ArrayType;
- if (array_type != null) {
+ if (array_type != null && has_array_length (expr.inner.target_value)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
append_array_length (expr, new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_length_cexpression (expr.inner, dim)));
}
@@ -5838,6 +5838,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
return glib_value.array_length_cvalues;
}
+
+ public bool has_array_length (TargetValue value) {
+ return value != null && ((GLibValue) value).array_length_cvalues != null;
+ }
}
public class Vala.GLibValue : TargetValue {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]