From 699c7c1b2c6d07612a43260ddbcee29ec1b5d59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 16 Jan 2025 15:25:20 +0100 Subject: [PATCH] run-test: Check argc before using argv We skip the filename argument when defining ARGV before actually checking that it was provided. Part-of: --- src/run-js-test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/run-js-test.c b/src/run-js-test.c index c1c933fc0..3f7c91eba 100644 --- a/src/run-js-test.c +++ b/src/run-js-test.c @@ -64,6 +64,12 @@ main (int argc, char **argv) g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR); g_irepository_prepend_search_path (SHELL_TYPELIB_DIR); + if (argc < 2) + { + g_printerr ("Missing filename\n"); + exit (1); + } + /* prepare command line arguments */ if (!gjs_context_define_string_array (js_context, "ARGV", argc - 2, (const char**)argv + 2, @@ -73,12 +79,6 @@ main (int argc, char **argv) exit (1); } - if (argc < 2) - { - g_printerr ("Missing filename\n"); - exit (1); - } - filename = argv[1]; title = g_filename_display_basename (filename); g_set_prgname (title);