From 94124ea693f1acb1c4e3720a8956d225dda57446 Mon Sep 17 00:00:00 2001 From: Magnus Edenhill Date: Fri, 17 Mar 2017 22:09:27 +0100 Subject: [PATCH] Avoid use of partially destroyed topic object (#1125) Identified and fixed by @benli123 #Changelog --- src/rdkafka_topic.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rdkafka_topic.c b/src/rdkafka_topic.c index 7126efbda3..3975d80fd8 100644 --- a/src/rdkafka_topic.c +++ b/src/rdkafka_topic.c @@ -109,16 +109,16 @@ void rd_kafka_topic_destroy_final (rd_kafka_itopic_t *rkt) { rd_kafka_assert(rkt->rkt_rk, rd_refcnt_get(&rkt->rkt_refcnt) == 0); - if (rkt->rkt_topic) - rd_kafkap_str_destroy(rkt->rkt_topic); + rd_kafka_wrlock(rkt->rkt_rk); + TAILQ_REMOVE(&rkt->rkt_rk->rk_topics, rkt, rkt_link); + rkt->rkt_rk->rk_topic_cnt--; + rd_kafka_wrunlock(rkt->rkt_rk); rd_kafka_assert(rkt->rkt_rk, rd_list_empty(&rkt->rkt_desp)); rd_list_destroy(&rkt->rkt_desp); - rd_kafka_wrlock(rkt->rkt_rk); - TAILQ_REMOVE(&rkt->rkt_rk->rk_topics, rkt, rkt_link); - rkt->rkt_rk->rk_topic_cnt--; - rd_kafka_wrunlock(rkt->rkt_rk); + if (rkt->rkt_topic) + rd_kafkap_str_destroy(rkt->rkt_topic); rd_kafka_anyconf_destroy(_RK_TOPIC, &rkt->rkt_conf);