[glib: 2/3] tests: Add missing assertion to guard against infinite loop




commit 51f322b74c6070fb295f577759b9a25228eb3a21
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Nov 17 10:38:12 2020 +0000

    tests: Add missing assertion to guard against infinite loop
    
    Since the loop variable changed signedness, it’s now possible for there
    to be an infinite loop if `get_match_count()` returns an error. Guard
    against that.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Coverity CID: #1436405

 glib/tests/regex.c | 1 +
 1 file changed, 1 insertion(+)
---
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index d86d32f9b..c57bd8cdc 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -1316,6 +1316,7 @@ test_match_all (gconstpointer d)
     g_assert (match_ok);
 
   match_count = g_match_info_get_match_count (match_info);
+  g_assert_cmpint (match_count, >=, 0);
 
   if (match_count != g_slist_length (data->expected))
     {


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