gapplicationcommandline: Handle the possibility empty args in an example

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 <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2022-01-31 14:46:08 +00:00
parent fc6d0ba3a8
commit 0d743e7ffb

View File

@ -119,6 +119,12 @@
* *
* argv = *arguments; * argv = *arguments;
* *
* if (argv[0] == NULL)
* {
* *exit_status = 0;
* return FALSE;
* }
*
* i = 1; * i = 1;
* while (argv[i]) * while (argv[i])
* { * {