[gnome-desktop-testing/wip/hadess/crash-unknown-option] Don't crash on unknown command-line options
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop-testing/wip/hadess/crash-unknown-option] Don't crash on unknown command-line options
- Date: Thu, 28 Nov 2019 13:49:37 +0000 (UTC)
commit 6f1a480b8d1a4db83cd5ce8bd3df23dae001dbab
Author: Bastien Nocera <hadess hadess net>
Date: Thu Nov 28 14:48:16 2019 +0100
Don't crash on unknown command-line options
gnome-desktop-testing-runner --foo
made it crash because it tried to access a number of arrays which
weren't allocated at option parsing time. Simply allocate them so we
access empty arrays instead of dereference a NULL pointer.
src/gnome-desktop-testing-runner.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-desktop-testing-runner.c b/src/gnome-desktop-testing-runner.c
index 7ddaaaf..7987936 100644
--- a/src/gnome-desktop-testing-runner.c
+++ b/src/gnome-desktop-testing-runner.c
@@ -855,6 +855,9 @@ main (int argc, char **argv)
memset (&appstruct, 0, sizeof (appstruct));
app = &appstruct;
+ app->pending_tests = g_hash_table_new (NULL, NULL);
+ app->tests = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
+ app->failed_test_msgs = g_ptr_array_new_with_free_func ((GDestroyNotify)g_free);
/* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
g_setenv ("GIO_USE_VFS", "local", TRUE);
@@ -889,10 +892,6 @@ main (int argc, char **argv)
else
app->parallel = opt_parallel;
- app->pending_tests = g_hash_table_new (NULL, NULL);
- app->tests = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
- app->failed_test_msgs = g_ptr_array_new_with_free_func ((GDestroyNotify)g_free);
-
if (opt_dirs)
datadirs_iter = (const char *const*) opt_dirs;
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]