GNOME Bugzilla – Bug 571322
length not correctly computed for array elements of array of array of strings
Last modified: 2010-10-16 13:43:09 UTC
The following code results in a segfault due to the fact that length of array inside the array of array of strings is evaluated to '-1'. ... string[][] search_result = this.search.Query ( 0, this.category, this.get_metadata_keys (), "", new string[0], "", false, new string[0], false, (int) offset, (int) max_count); ArrayList<MediaObject> children = new ArrayList<MediaObject> (); /* Iterate through all items */ for (uint i = 0; i < search_result.length; i++) { string child_path = search_result[i][0]; string[] metadata = this.slice_strv_tail (search_result[i], 2); MediaObject item = this.fetch_item_by_path (child_path, metadata); children.add (item); } ... private string[] slice_strv_tail (string[] strv, int index) { string[] slice = new string[strv.length - index]; for (int i = 0; i < slice.length; i++) { slice[i] = strv[i + index]; } return slice; }
using this function to calculate the length of the strv in the above code make everything right: private int get_strv_length (string[] strv) { int i = 0; for (i = 0; strv[i] != null; i++); return i + 1; }
The problems seems to be here: gobject/valaccodemethodcallmodule.vala:416 Don't have any clue on how to fix it though. :(
commit cc435dd6ec069b87e986fa454e80e5fe80a0df72 Author: Jürg Billeter <j@bitron.ch> Date: Sat Oct 16 15:17:23 2010 +0200 Report error when trying to use stacked arrays Stacked array support was never completed. Report an error instead of generating incorrect C code. Fixes bug 546603, bug 548428, bug 548429, bug 565865, bug 565872, bug 571322, bug 572649, and bug 576611.