From 0d743e7ffbf1edff5e00e67a9bed7bfa507901f6 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 31 Jan 2022 14:46:08 +0000 Subject: [PATCH] gapplicationcommandline: Handle the possibility empty args in an example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While it’s not usual, it is possible for applications to be called with an empty `argv` by a process (ab)using `execve()`. Modify the `GApplication` code example to handle that possibility, so that anyone copying the example isn’t introducing a bug into their program immediately. Signed-off-by: Philip Withnall --- gio/gapplicationcommandline.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gio/gapplicationcommandline.c b/gio/gapplicationcommandline.c index 937b87d22..d7be108bf 100644 --- a/gio/gapplicationcommandline.c +++ b/gio/gapplicationcommandline.c @@ -119,6 +119,12 @@ * * argv = *arguments; * + * if (argv[0] == NULL) + * { + * *exit_status = 0; + * return FALSE; + * } + * * i = 1; * while (argv[i]) * {