diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2013-06-13 16:47:13 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2013-06-13 16:47:13 +0200 |
commit | 0cc5ca825656dbb2dc91fb130924abe66c97b254 (patch) | |
tree | 6f815e726eb0f543115823c7940c1e325fbe195d /dissector_eth.c | |
parent | bdf2285959f985bb1d9a92ba22eefadc6d85a393 (diff) |
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 <tklauser@distanz.ch>
Diffstat (limited to 'dissector_eth.c')
-rw-r--r-- | dissector_eth.c | 8 |
1 files 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'); |