From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [B.A.T.M.A.N.] [PATCH 2/3] batctl: Free hash iterator when breaking out of loop
Date: Sat, 24 May 2014 15:56:17 +0200 [thread overview]
Message-ID: <1400939778-12886-2-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1400939778-12886-1-git-send-email-sven@narfation.org>
The hash iterator is automatically allocated and freed by the hash_iterate
function. But when using break (or goto outside of loop) during the iteration
loop, the caller has to handle the free-operation of the hash_iterator to avoid
memory leaks.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
bisect_iv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bisect_iv.c b/bisect_iv.c
index e9e7326..7105c78 100644
--- a/bisect_iv.c
+++ b/bisect_iv.c
@@ -1304,8 +1304,10 @@ static void trace_seqnos(char *trace_orig, long long seqno_min, long long seqno_
res = seqno_trace_add(&trace_list, bat_node, seqno_event, print_trace);
- if (res < 1)
+ if (res < 1) {
+ hash_iterate_free(hashit);
goto out;
+ }
}
}
}
--
2.0.0.rc2
next prev parent reply other threads:[~2014-05-24 13:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-24 13:56 [B.A.T.M.A.N.] [PATCH 1/3] batctl: Import hash table version from alfred Sven Eckelmann
2014-05-24 13:56 ` Sven Eckelmann [this message]
2014-06-12 9:29 ` [B.A.T.M.A.N.] [PATCH 2/3] batctl: Free hash iterator when breaking out of loop Marek Lindner
2014-05-24 13:56 ` [B.A.T.M.A.N.] [PATCH 3/3] batctl: Use memleak/error path free implementation of hash_resize Sven Eckelmann
2014-05-27 14:23 ` [B.A.T.M.A.N.] [PATCHv2 " Sven Eckelmann
2014-06-12 9:30 ` Marek Lindner
2014-06-12 9:28 ` [B.A.T.M.A.N.] [PATCH 1/3] batctl: Import hash table version from alfred Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1400939778-12886-2-git-send-email-sven@narfation.org \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox