[B.A.T.M.A.N.] [PATCH 2/3] batctl: Free hash iterator when breaking out of loop

Sven Eckelmann sven at narfation.org
Sat May 24 15:56:17 CEST 2014


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 at 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



More information about the B.A.T.M.A.N mailing list