From 4bb6b588bfeb31b385c0082d7ca88293ff55ef8e Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 27 Jun 2023 13:16:07 -0700 Subject: [PATCH] libsysprof-profile: avoid alloca for counter state --- src/libsysprof-profile/sysprof-network-usage.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsysprof-profile/sysprof-network-usage.c b/src/libsysprof-profile/sysprof-network-usage.c index a1722203..4a4160f2 100644 --- a/src/libsysprof-profile/sysprof-network-usage.c +++ b/src/libsysprof-profile/sysprof-network-usage.c @@ -109,14 +109,14 @@ sysprof_network_usage_record_fiber (gpointer user_data) { char buf[4096*2]; Record *record = user_data; - SysprofCaptureCounterValue *values; + g_autofree SysprofCaptureCounterValue *values = NULL; + g_autofree guint *ids = NULL; g_autoptr(GArray) devices = NULL; g_autoptr(GError) error = NULL; SysprofCaptureWriter *writer; SysprofCaptureCounter ctr[2] = {0}; g_autofd int stat_fd = -1; LineReader reader; - guint *ids; guint combined_rx_id; guint combined_tx_id; gssize n_read; @@ -212,8 +212,8 @@ sysprof_network_usage_record_fiber (gpointer user_data) g_array_append_val (devices, dev); } - values = g_alloca (sizeof (SysprofCaptureCounterValue) * (devices->len + 2)); - ids = g_alloca (sizeof (guint) * (devices->len + 2)); + values = g_new0 (SysprofCaptureCounterValue, (devices->len*2) + 2); + ids = g_new0 (guint, (devices->len*2) + 2); ids[0] = combined_rx_id; ids[1] = combined_tx_id; for (guint i = 0; i < devices->len; i++)