From 11654811ef304a56cc35743b4cd6547a25338ed5 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 31 Jan 2022 14:48:58 +0000 Subject: [PATCH] gdesktopappinfo: Add checks for empty argv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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);