2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/queue-test.c (main): Add some tests for off-by-one errors.
+
+ * glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
+ error. (#139703, Philippe Blain)
+
* tests/testglib.c (main): Add testcases for g_message() involving
non-printable and unsafe characters.
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/queue-test.c (main): Add some tests for off-by-one errors.
+
+ * glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
+ error. (#139703, Philippe Blain)
+
* tests/testglib.c (main): Add testcases for g_message() involving
non-printable and unsafe characters.
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/queue-test.c (main): Add some tests for off-by-one errors.
+
+ * glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
+ error. (#139703, Philippe Blain)
+
* tests/testglib.c (main): Add testcases for g_message() involving
non-printable and unsafe characters.
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/queue-test.c (main): Add some tests for off-by-one errors.
+
+ * glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
+ error. (#139703, Philippe Blain)
+
* tests/testglib.c (main): Add testcases for g_message() involving
non-printable and unsafe characters.
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/queue-test.c (main): Add some tests for off-by-one errors.
+
+ * glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
+ error. (#139703, Philippe Blain)
+
* tests/testglib.c (main): Add testcases for g_message() involving
non-printable and unsafe characters.
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/queue-test.c (main): Add some tests for off-by-one errors.
+
+ * glib/gqueue.c (g_queue_pop_nth_link): Fix an off-by-one
+ error. (#139703, Philippe Blain)
+
* tests/testglib.c (main): Add testcases for g_message() involving
non-printable and unsafe characters.
g_return_val_if_fail (queue != NULL, NULL);
- if (n > queue->length)
+ if (n >= queue->length)
return NULL;
link = g_queue_peek_nth_link (queue, n);
g_queue_foreach (q2, remove_item, q2);
check_integrity (q2);
check_integrity (q);
+
+ /* some checks for off by one errors */
+ g_queue_push_tail (q, GINT_TO_POINTER (1234));
+ check_integrity (q);
+ node = g_queue_peek_tail_link (q);
+ g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
+ node = g_queue_peek_nth_link (q, g_queue_get_length (q));
+ g_assert (node == NULL);
+ node = g_queue_peek_nth_link (q, g_queue_get_length (q) - 1);
+ g_assert (node->data == GINT_TO_POINTER (1234));
+ node = g_queue_pop_nth_link (q, g_queue_get_length (q));
+ g_assert (node == NULL);
+ node = g_queue_pop_nth_link (q, g_queue_get_length (q) - 1);
+ g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
g_queue_free (q);
if (argc > 1)
random_test (strtol (args[1], NULL, 0));
else
- random_test (time (0));
-
+ random_test (time (0));
+
return 0;
}