[B.A.T.M.A.N.] [PATCH 03/10] batadv-vis: Avoid memory leak when tl parsing failed

Sven Eckelmann
2014-05-24T11:44:08Z

The parsing function for the local translation table can fail to convert the
mac address and then jumps out of the function. This leaks the earlier
allocated v_entry.

Signed-off-by: Sven Eckelmann <sven@narfation.org>

---
vis/vis.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/vis/vis.c b/vis/vis.c
index 9031b27..a5ac664 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -213,8 +213,10 @@ static int parse_transtable_local(struct globals *globals)
continue;

mac = str_to_mac(tptr);
- if (!mac)
+ if (!mac) {
+ free(v_entry);
continue;
+ }

memcpy(v_entry->v.mac, mac, ETH_ALEN);
v_entry->v.ifindex = 255;
--
2.0.0.rc2