[model] ModelAbstractSortedList: Fix an infinite loop
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [model] ModelAbstractSortedList: Fix an infinite loop
- Date: Thu, 11 Mar 2010 06:35:35 +0000 (UTC)
commit 1887af78502d3ae997d5fd27f7d6510862fd1416
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Mar 11 00:58:21 2010 -0500
ModelAbstractSortedList: Fix an infinite loop
When removing an item that isn't in the list an infinite loop occurs due
to 'j' not being properly incremented. Fix that, and make incrementing
of the loop variables more consistent in general.
model/model.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/model/model.c b/model/model.c
index 6a06662..1cecf33 100644
--- a/model/model.c
+++ b/model/model.c
@@ -2286,7 +2286,7 @@ model_abstract_sorted_list_merge (ModelAbstractSortedList *sorted,
g_object_unref (old_objects[i]);
class->free_key (sorted, old_keys[i]);
removed = inserted = TRUE;
- i++, j++, k++;
+ k++;
}
else if (this_mode == 'i' || this_mode == 'I')
{
@@ -2295,17 +2295,18 @@ model_abstract_sorted_list_merge (ModelAbstractSortedList *sorted,
sorted->priv->objects[k] = old_objects[i];
sorted->priv->keys[k] = old_keys[i];
- i++, j++, k++;
+ k++;
}
else if (this_mode == 'd' || this_mode == 'D')
{
g_object_unref (old_objects[i]);
class->free_key (sorted, old_keys[i]);
removed = TRUE;
- i++, j++;
}
else
g_error ("unrecognised mode: `%c'\n", this_mode);
+
+ i++, j++;
}
else if (cmp < 0)
{
@@ -2325,7 +2326,7 @@ model_abstract_sorted_list_merge (ModelAbstractSortedList *sorted,
&sorted->priv->keys[k],
&sorted->priv->objects[k]);
inserted = TRUE;
- j++, k++;
+ k++;
}
else if (this_mode == 'd' || this_mode == 'D')
{
@@ -2334,6 +2335,8 @@ model_abstract_sorted_list_merge (ModelAbstractSortedList *sorted,
}
else
g_error ("unrecognised mode: `%c'", this_mode);
+
+ j++;
}
if (in_change_set)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]