[libhandy/libhandy-1-2] stackable-box: Null check visible child in find_swipeable_child()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/libhandy-1-2] stackable-box: Null check visible child in find_swipeable_child()
- Date: Mon, 21 Jun 2021 08:48:34 +0000 (UTC)
commit 58641c1582f5bf5a5cb3e9f9193f0febb4ec9a4b
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Jun 18 14:51:07 2021 +0500
stackable-box: Null check visible child in find_swipeable_child()
Fixes https://gitlab.gnome.org/GNOME/libhandy/-/issues/444
src/hdy-stackable-box.c | 4 ++++
tests/test-deck.c | 6 ++++++
tests/test-leaflet.c | 6 ++++++
3 files changed, 16 insertions(+)
---
diff --git a/src/hdy-stackable-box.c b/src/hdy-stackable-box.c
index 4d003c0e..7ebeb66f 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -1197,6 +1197,10 @@ find_swipeable_child (HdyStackableBox *self,
HdyStackableBoxChildInfo *child = NULL;
children = g_list_find (self->children, self->visible_child);
+
+ if (children == NULL)
+ return NULL;
+
do {
children = (direction == HDY_NAVIGATION_DIRECTION_BACK) ? children->prev : children->next;
diff --git a/tests/test-deck.c b/tests/test-deck.c
index 9a1fd920..51ef5129 100644
--- a/tests/test-deck.c
+++ b/tests/test-deck.c
@@ -54,6 +54,12 @@ test_hdy_deck_navigate (void)
deck = HDY_DECK (hdy_deck_new ());
g_assert_nonnull (deck);
+ result = hdy_deck_navigate (deck, HDY_NAVIGATION_DIRECTION_BACK);
+ g_assert_false (result);
+
+ result = hdy_deck_navigate (deck, HDY_NAVIGATION_DIRECTION_FORWARD);
+ g_assert_false (result);
+
for (i = 0; i < 2; i++) {
children[i] = gtk_label_new ("");
g_assert_nonnull (children[i]);
diff --git a/tests/test-leaflet.c b/tests/test-leaflet.c
index 506c0a44..f06ad9a3 100644
--- a/tests/test-leaflet.c
+++ b/tests/test-leaflet.c
@@ -66,6 +66,12 @@ test_hdy_leaflet_navigate (void)
leaflet = HDY_LEAFLET (hdy_leaflet_new ());
g_assert_nonnull (leaflet);
+ result = hdy_leaflet_navigate (leaflet, HDY_NAVIGATION_DIRECTION_BACK);
+ g_assert_false (result);
+
+ result = hdy_leaflet_navigate (leaflet, HDY_NAVIGATION_DIRECTION_FORWARD);
+ g_assert_false (result);
+
for (i = 0; i < 3; i++) {
children[i] = gtk_label_new ("");
g_assert_nonnull (children[i]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]