From e18ff51d4f4eb073b5aa3dab1d762b5d8abbeb2f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 9 Jan 2019 21:58:26 +0100 Subject: [PATCH] tests: don't use alloca() in tests The only purpose of using alloca() to avoid the overhead of heap-allocation and possible save a line in source code for managing/freeing the heap allocation. For tests we don't care about performance, and (in this case) the code does not get any shorter. Avoid alloca() in tests, because alloca() is something to search for when reviewing code for stack overflows. No need to have such false positives show up in tests. --- src/tests/test-general.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/test-general.c b/src/tests/test-general.c index 2db6e60f6c..f065d12721 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -352,13 +352,13 @@ _match_connection (GSList *connections, gint64 default_v4_metric, gint64 default_v6_metric) { - NMConnection **list; + gs_free NMConnection **list = NULL; guint i, len; len = g_slist_length (connections); g_assert (len < 10); - list = g_alloca ((len + 1) * sizeof (NMConnection *)); + list = g_malloc ((len + 1) * sizeof (NMConnection *)); for (i = 0; i < len; i++, connections = connections->next) { g_assert (connections); g_assert (connections->data);