core: Fix possible crash in ostree_mutable_tree_walk()

If the starting index is beyond the end of the list, it's a programming
error. Previously, the code was trying to raise a runtime error, but
actually causing a segfault.

This was detected by test code in test-mutable-tree.c, which is removed
in this commit because it should now not be possible to crash here.

https://bugzilla.gnome.org/747032
This commit is contained in:
Sam Thursfield authored and Matthew Barnes committed 2015-03-31 13:04:31 -04:00
1 parent 3ffc277bed
commit d667ebe156
2 files changed
+3 -12

No files matched your search

+3 -5
View File
@@ -315,11 +315,9 @@ ostree_mutable_tree_walk (OstreeMutableTree *self,
OstreeMutableTree **out_subdir,
GError **error)
{
if (start >= split_path->len)
{
return set_error_noent (error, (char*)split_path->pdata[start]);
}
else if (start == split_path->len - 1)
g_return_val_if_fail (start < split_path->len, FALSE);
if (start == split_path->len - 1)
{
*out_subdir = g_object_ref (self);
return TRUE;