[glib/ebassi/gcc-12-fixes: 2/2] Fix check before a memcpy




commit e08c954693fdcfceda2de59cca93a76125f4fca6
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Sep 2 12:52:35 2022 +0100

    Fix check before a memcpy
    
    The search_total_results address is always going to be non-zero, so the
    check will always evaluate to true, and GCC is kind enough to point this
    out to us.
    
    The appropriate fix is checking if the size of the search results array
    is larger than zero, and if so, copy them into the total results array.

 gio/gdesktopappinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 85b424dda8..56cfa4cdbb 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -710,7 +710,7 @@ merge_directory_results (void)
       static_total_results = g_renew (struct search_result, static_total_results, 
static_total_results_allocated);
     }
 
-  if (static_total_results + static_total_results_size != 0)
+  if (static_search_results_size != 0)
     memcpy (static_total_results + static_total_results_size,
             static_search_results,
             static_search_results_size * sizeof (struct search_result));


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