[ovs-dev] [PATCH] dns-resolve: Fix a bug that frees node inside HMAP_FOR_EACH

Yifeng Sun pkusunyifeng at gmail.com
Thu Aug 16 12:28:26 UTC 2018


HMAP_FOR_EACH_SAFE should be used when node is freed inside.

Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
---
 lib/dns-resolve.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dns-resolve.c b/lib/dns-resolve.c
index 299ab27ab5ca..3c6d70e8fbba 100644
--- a/lib/dns-resolve.c
+++ b/lib/dns-resolve.c
@@ -162,8 +162,8 @@ dns_resolve_destroy(void)
         ub_ctx_delete(ub_ctx__);
         ub_ctx__ = NULL;
 
-        struct resolve_request *req;
-        HMAP_FOR_EACH(req, hmap_node, &all_reqs__) {
+        struct resolve_request *req, *next;
+        HMAP_FOR_EACH_SAFE (req, next, hmap_node, &all_reqs__) {
             ub_resolve_free(req->ub_result);
             free(req->addr);
             free(req->name);
-- 
2.7.4



More information about the dev mailing list