mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 13:40:11 +01:00
libnm: avoid heap allocation in _nm_utils_strdict_to_dbus()
This commit is contained in:
parent
df6714102c
commit
f36a0d408b
1 changed files with 8 additions and 2 deletions
|
|
@ -825,9 +825,15 @@ _nm_utils_strdict_to_dbus (const GValue *prop_value)
|
|||
if (len == 1)
|
||||
g_variant_builder_add (&builder, "{ss}", key, value);
|
||||
else {
|
||||
gs_free NMUtilsNamedValue *idx = NULL;
|
||||
gs_free NMUtilsNamedValue *idx_free = NULL;
|
||||
NMUtilsNamedValue *idx;
|
||||
|
||||
if (len > 300 / sizeof (NMUtilsNamedValue)) {
|
||||
idx_free = g_new (NMUtilsNamedValue, len);
|
||||
idx = idx_free;
|
||||
} else
|
||||
idx = g_alloca (sizeof (NMUtilsNamedValue) * len);
|
||||
|
||||
idx = g_new (NMUtilsNamedValue, len);
|
||||
i = 0;
|
||||
do {
|
||||
idx[i].name = key;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue