From fec1c43f809d6bffffd8f56554807497d7be5ac0 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 2 Jan 2019 10:11:22 +0100 Subject: ublox: don't create array with totally unrelated size --- plugins/ublox/mm-modem-helpers-ublox.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plugins/ublox/mm-modem-helpers-ublox.c') diff --git a/plugins/ublox/mm-modem-helpers-ublox.c b/plugins/ublox/mm-modem-helpers-ublox.c index e69053d5..442ff601 100644 --- a/plugins/ublox/mm-modem-helpers-ublox.c +++ b/plugins/ublox/mm-modem-helpers-ublox.c @@ -1290,8 +1290,6 @@ mm_ublox_build_ubandsel_set_command (GArray *bands, if (bands->len == 1 && g_array_index (bands, MMModemBand, 0) == MM_MODEM_BAND_ANY) return g_strdup ("+UBANDSEL=0"); - ubandsel_nums = g_array_sized_new (FALSE, FALSE, sizeof (guint), G_N_ELEMENTS (band_configuration)); - for (i = 0; i < G_N_ELEMENTS (band_configuration); i++) { if (g_str_has_prefix (model, band_configuration[i].model)) break; @@ -1300,10 +1298,11 @@ mm_ublox_build_ubandsel_set_command (GArray *bands, if (i == G_N_ELEMENTS (band_configuration)) { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Unknown modem model %s", model); - g_array_unref (ubandsel_nums); return NULL; } + ubandsel_nums = g_array_sized_new (FALSE, FALSE, sizeof (guint), bands->len); + for (j = 0; j < bands->len; j++) { MMModemBand band; gboolean found = FALSE; -- cgit v1.2.3-70-g09d2