summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-08-01 15:04:39 +0200
committerThomas Haller <thaller@redhat.com>2019-08-01 15:04:41 +0200
commitece270ea5fa058e3c8448c3dfe5676ff67311b6c (patch)
tree1e99faca65e8b315e34fdcc3cf11e21025f1aab1
parent72e604c8e4a0d89c9474a7048d330a9bc8406812 (diff)
downloadNetworkManager-ece270ea5fa058e3c8448c3dfe5676ff67311b6c.tar.gz
core/lldp: fix memleak in _lldp_attr_take_str_ptr()
Valgrind complains: ==26355== 32 bytes in 2 blocks are definitely lost in loss record 2,829 of 6,716 ==26355== at 0x4838748: malloc (vg_replace_malloc.c:308) ==26355== by 0x483AD63: realloc (vg_replace_malloc.c:836) ==26355== by 0x4F6AD4F: g_realloc (in /usr/lib64/libglib-2.0.so.0.6000.6) ==26355== by 0x4F87B33: ??? (in /usr/lib64/libglib-2.0.so.0.6000.6) ==26355== by 0x4F87B96: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.6000.6) ==26355== by 0x2D66E1: nm_utils_buf_utf8safe_escape (nm-shared-utils.c:1911) ==26355== by 0x4113B0: lldp_neighbor_new (nm-lldp-listener.c:676) ==26355== by 0x412788: process_lldp_neighbor (nm-lldp-listener.c:882) ==26355== by 0x4135CF: lldp_event_handler (nm-lldp-listener.c:931) ==26355== by 0x422CDB: lldp_callback (sd-lldp.c:50) ==26355== by 0x4235F9: lldp_add_neighbor (sd-lldp.c:166) ==26355== by 0x423679: lldp_handle_datagram (sd-lldp.c:189) ==26355== by 0x423C8B: lldp_receive_datagram (sd-lldp.c:235) ==26355== by 0x2F887A: source_dispatch (sd-event.c:2832) ==26355== by 0x2FAD43: sd_event_dispatch (sd-event.c:3245) ==26355== by 0x2D9237: event_dispatch (nm-sd.c:51) ==26355== by 0x4F64EDC: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6000.6) ==26355== by 0x4F6526F: ??? (in /usr/lib64/libglib-2.0.so.0.6000.6) ==26355== by 0x4F655A2: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6000.6) ==26355== by 0x140932: main (main.c:465) ==26355==
-rw-r--r--src/devices/nm-lldp-listener.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/devices/nm-lldp-listener.c b/src/devices/nm-lldp-listener.c
index c0d783158c..2dc38d4ca8 100644
--- a/src/devices/nm-lldp-listener.c
+++ b/src/devices/nm-lldp-listener.c
@@ -232,8 +232,10 @@ _lldp_attr_take_str_ptr (LldpAttrData *pdata, LldpAttrId attr_id, char *str)
pdata = &pdata[attr_id];
/* we ignore duplicate fields silently. */
- if (pdata->attr_type != LLDP_ATTR_TYPE_NONE)
+ if (pdata->attr_type != LLDP_ATTR_TYPE_NONE) {
+ g_free (str);
return;
+ }
pdata->attr_type = LLDP_ATTR_TYPE_STRING;
pdata->v_string = str;