[epiphany/gnome-3-34] find-toolbar: Correctly handle zero matches



commit 9ef1d63832384e1246a53d4eb036cac3cb098f4b
Author: Dimitrios Christidis <dimitrios christidis me>
Date:   Sun Nov 3 18:34:05 2019 +0000

    find-toolbar: Correctly handle zero matches
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/984
    
    
    (cherry picked from commit 1a9108f334b3a08ac52b54a18520111f13c700f8)

 embed/ephy-find-toolbar.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/embed/ephy-find-toolbar.c b/embed/ephy-find-toolbar.c
index 02a7df9a3..8788a4c28 100644
--- a/embed/ephy-find-toolbar.c
+++ b/embed/ephy-find-toolbar.c
@@ -598,18 +598,24 @@ ephy_find_toolbar_set_web_view (EphyFindToolbar *toolbar,
 void
 ephy_find_toolbar_find_next (EphyFindToolbar *toolbar)
 {
-  toolbar->current_match++;
-  if (toolbar->current_match > toolbar->num_matches)
-    toolbar->current_match = 1;
+  if (toolbar->num_matches) {
+    toolbar->current_match++;
+    if (toolbar->current_match > toolbar->num_matches)
+      toolbar->current_match = 1;
+  }
+
   webkit_find_controller_search_next (toolbar->controller);
 }
 
 void
 ephy_find_toolbar_find_previous (EphyFindToolbar *toolbar)
 {
-  toolbar->current_match--;
-  if (toolbar->current_match < 1)
-    toolbar->current_match = toolbar->num_matches;
+  if (toolbar->num_matches) {
+    g_assert (toolbar->current_match > 0);
+    toolbar->current_match--;
+    if (toolbar->current_match < 1)
+      toolbar->current_match = toolbar->num_matches;
+  }
 
   webkit_find_controller_search_previous (toolbar->controller);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]