run-test: Check argc before using argv
We skip the filename argument when defining ARGV before actually checking that it was provided. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
This commit is contained in:
parent
e7691bd3df
commit
699c7c1b2c
@ -64,6 +64,12 @@ main (int argc, char **argv)
|
|||||||
g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR);
|
g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR);
|
||||||
g_irepository_prepend_search_path (SHELL_TYPELIB_DIR);
|
g_irepository_prepend_search_path (SHELL_TYPELIB_DIR);
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
g_printerr ("Missing filename\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
/* prepare command line arguments */
|
/* prepare command line arguments */
|
||||||
if (!gjs_context_define_string_array (js_context, "ARGV",
|
if (!gjs_context_define_string_array (js_context, "ARGV",
|
||||||
argc - 2, (const char**)argv + 2,
|
argc - 2, (const char**)argv + 2,
|
||||||
@ -73,12 +79,6 @@ main (int argc, char **argv)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 2)
|
|
||||||
{
|
|
||||||
g_printerr ("Missing filename\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
filename = argv[1];
|
filename = argv[1];
|
||||||
title = g_filename_display_basename (filename);
|
title = g_filename_display_basename (filename);
|
||||||
g_set_prgname (title);
|
g_set_prgname (title);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user