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:
parent
3ffc277bed
commit
d667ebe156
|
|
@ -315,11 +315,9 @@ ostree_mutable_tree_walk (OstreeMutableTree *self,
|
||||||
OstreeMutableTree **out_subdir,
|
OstreeMutableTree **out_subdir,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
if (start >= split_path->len)
|
g_return_val_if_fail (start < split_path->len, FALSE);
|
||||||
{
|
|
||||||
return set_error_noent (error, (char*)split_path->pdata[start]);
|
if (start == split_path->len - 1)
|
||||||
}
|
|
||||||
else if (start == split_path->len - 1)
|
|
||||||
{
|
{
|
||||||
*out_subdir = g_object_ref (self);
|
*out_subdir = g_object_ref (self);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,6 @@ test_mutable_tree_walk (void)
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
gs_unref_object OstreeMutableTree *subdir = NULL;
|
|
||||||
g_assert_false (ostree_mutable_tree_walk (tree, split_path, 10, &subdir, &error));
|
|
||||||
g_assert_null (subdir);
|
|
||||||
g_clear_error (&error);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
gs_unref_object OstreeMutableTree *subdir = NULL;
|
gs_unref_object OstreeMutableTree *subdir = NULL;
|
||||||
gs_unref_object OstreeMutableTree *a = NULL;
|
gs_unref_object OstreeMutableTree *a = NULL;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue