From 0cc5ca825656dbb2dc91fb130924abe66c97b254 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 13 Jun 2013 16:47:13 +0200 Subject: dissector: eth: Free allocated record if line is skipped We would currently leak the record in case we skip a line, fix this by xfree()ing the memory in these cases. Signed-off-by: Tobias Klauser --- dissector_eth.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dissector_eth.c b/dissector_eth.c index 5a06906..3686fb9 100644 --- a/dissector_eth.c +++ b/dissector_eth.c @@ -147,13 +147,17 @@ static void dissector_init_ports(enum ports which) p = xmalloc(sizeof(*p)); p->id = strtol(ptr, &end, 0); /* not a valid line, skip */ - if (p->id == 0 && end == ptr) + if (p->id == 0 && end == ptr) { + xfree(p); continue; + } ptr = strstr(buff, ", "); /* likewise */ - if (!ptr) + if (!ptr) { + xfree(p); continue; + } ptr += strlen(", "); ptr = strtrim_right(ptr, '\n'); -- cgit v1.2.3-54-g00ecf