[glib: 4/8] gdesktopappinfo: Add checks for empty argv




commit 11654811ef304a56cc35743b4cd6547a25338ed5
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Jan 31 14:48:58 2022 +0000

    gdesktopappinfo: Add checks for empty argv
    
    There shouldn’t be any issues here with empty argv arrays since an empty
    `Exec=` line is already checked for. Encode that explicitly with an
    assertion.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 gio/gdesktopappinfo.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 80f936ca1..0bc8e96c9 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -1880,6 +1880,10 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
       else
         {
           char *t;
+
+          /* Since @exec is not an empty string, there must be at least one
+           * argument, so dereferencing argv[0] should return non-NULL. */
+          g_assert (argc > 0);
           t = g_find_program_in_path (argv[0]);
           g_strfreev (argv);
 


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