Commit f7e05d15 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

Fix crash when using multi-dimensional arrays, patch by Amos Brocco, fixes

2008-07-22  Jürg Billeter  <j@bitron.ch>

	* gobject/valaccodearraycreationexpressionbinding.vala:

	Fix crash when using multi-dimensional arrays,
	patch by Amos Brocco, fixes bug 544145

svn path=/trunk/; revision=1721
parent 701679ee
2008-07-22 Jürg Billeter <j@bitron.ch>
* gobject/valaccodearraycreationexpressionbinding.vala:
Fix crash when using multi-dimensional arrays,
patch by Amos Brocco, fixes bug 544145
2008-07-22 Jürg Billeter <j@bitron.ch>
* vala/valaparser.vala:
......
......@@ -3,6 +3,7 @@ The Vala team would like to thank the following contributors:
Alberto Ruiz
Alexandre Moreira
Ali Sabil
Amos Brocco
Andrea Del Signore
Andreas Brauchli
Arwed von Merkatz
......
......@@ -44,6 +44,8 @@ public class Vala.CCodeArrayCreationExpressionBinding : CCodeExpressionBinding {
gnew.add_argument (new CCodeIdentifier (expr.element_type.get_cname ()));
bool first = true;
CCodeExpression cexpr = null;
// iterate over each dimension
foreach (Expression size in expr.get_sizes ()) {
CCodeExpression csize = (CCodeExpression) size.ccodenode;
......@@ -57,11 +59,6 @@ public class Vala.CCodeArrayCreationExpressionBinding : CCodeExpressionBinding {
csize = new CCodeParenthesizedExpression (new CCodeAssignment (name_cnode, csize));
}
if (expr.element_type.data_type != null && expr.element_type.data_type.is_reference_type ()) {
// add extra item to have array NULL-terminated for all reference types
csize = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, csize, new CCodeConstant ("1"));
}
if (first) {
cexpr = csize;
first = false;
......@@ -69,6 +66,12 @@ public class Vala.CCodeArrayCreationExpressionBinding : CCodeExpressionBinding {
cexpr = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, cexpr, csize);
}
}
// add extra item to have array NULL-terminated for all reference types
if (expr.element_type.data_type != null && expr.element_type.data_type.is_reference_type ()) {
cexpr = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cexpr, new CCodeConstant ("1"));
}
gnew.add_argument (cexpr);
if (expr.initializer_list != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment