CBL-Mariner/SPECS-EXTENDED/gnome-desktop-testing/0001-Don-t-crash-on-unknown...

42 строки
1.6 KiB
Diff

From 6f1a480b8d1a4db83cd5ce8bd3df23dae001dbab Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 28 Nov 2019 14:48:16 +0100
Subject: [PATCH] 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
--
2.23.0