mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-15 17:28:27 +02:00
ifcfg-rh: fix memleak in make_ip4_setting()
This commit is contained in:
parent
9d04d62255
commit
d1a0229083
1 changed files with 4 additions and 3 deletions
|
|
@ -55,6 +55,7 @@
|
|||
#include "nm-platform.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-logging.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "shvar.h"
|
||||
|
|
@ -890,7 +891,7 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
char *value = NULL;
|
||||
char *route_path = NULL;
|
||||
char *method;
|
||||
char *gateway = NULL;
|
||||
gs_free char *gateway = NULL;
|
||||
gint32 i;
|
||||
shvarFile *network_ifcfg;
|
||||
shvarFile *route_ifcfg;
|
||||
|
|
@ -962,7 +963,6 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
(void) nm_setting_ip_config_add_address (s_ip4, addr);
|
||||
nm_ip_address_unref (addr);
|
||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL);
|
||||
g_free (gateway);
|
||||
}
|
||||
return NM_SETTING (s_ip4);
|
||||
} else {
|
||||
|
|
@ -1012,6 +1012,8 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
for (i = -1; i < 256; i++) {
|
||||
NMIPAddress *addr = NULL;
|
||||
|
||||
/* gateway will only be set if still unset. Hence, we don't leak gateway
|
||||
* here by calling read_full_ip4_address() repeatedly */
|
||||
if (!read_full_ip4_address (ifcfg, network_file, i, NULL, &addr, &gateway, error))
|
||||
goto done;
|
||||
|
||||
|
|
@ -1144,7 +1146,6 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
return NM_SETTING (s_ip4);
|
||||
|
||||
done:
|
||||
g_free (gateway);
|
||||
g_free (route_path);
|
||||
g_object_unref (s_ip4);
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue