Workaround vala 0.10 bug LP 1250543
authorKevin Wasserman <kevin.wasserman@painless-security.com>
Thu, 14 Nov 2013 17:01:11 +0000 (12:01 -0500)
committerKevin Wasserman <kevin.wasserman@painless-security.com>
Thu, 14 Nov 2013 17:01:11 +0000 (12:01 -0500)
vala 0.10 appears to generate completely broken c code when
attempting to drectly access the length of an array property.
Fixes segfault in moonshot-webp on Centos.

src/moonshot-provisioning-common.vala

index 347bd32..73704d4 100644 (file)
@@ -1,3 +1,4 @@
+
 namespace WebProvisioning
 { 
   IdCard card;
@@ -168,16 +169,16 @@ namespace WebProvisioning
     /* Rules */
     else if (stack.nth_data(0) == "pattern" && pattern_handler (stack))
     {
-      /* use temp index to workaround valac bug */ 
-      int index = card.rules.length - 1;
-      card.rules[index].pattern = text;
+      /* use temp array to workaround valac 0.10 bug accessing array property length */ 
+      var temp = card.rules;
+      card.rules[temp.length - 1].pattern = text;
     }
     else if (stack.nth_data(0) == "always-confirm" && always_confirm_handler (stack))
     {
       if (text == "true" || text == "false") {
-        /* use temp index to workaround valac bug */ 
-        int index = card.rules.length - 1;
-        card.rules[index].always_confirm = text;
+        /* use temp array to workaround valac 0.10 bug accessing array property length*/
+        var temp = card.rules;
+        card.rules[temp.length - 1].always_confirm = text;
       }
     }
     /*Trust anchor*/