diff --git a/src/micro.c b/src/micro.c index deba519b..c018ca05 100644 --- a/src/micro.c +++ b/src/micro.c @@ -327,13 +327,12 @@ void micro_release_on_endpoint_complete(void *closure) micro_lock_endpoint(ep); ep->is_draining = false; sub = ep->sub; - // ep->sub = NULL; + ep->sub = NULL; // Force the subscription to be destroyed now, so NULL out the pointer to avoid a double free. ep->refs--; destroyEndpoint = (ep->refs == 0); micro_unlock_endpoint(ep); - - // Force the subscription to be destroyed now. - // natsSubscription_Destroy(sub); + + natsSubscription_Destroy(sub); _lock_service(m); diff --git a/src/sub.c b/src/sub.c index 91ac3af2..790881b6 100644 --- a/src/sub.c +++ b/src/sub.c @@ -113,7 +113,6 @@ _freeSub(natsSubscription *sub) _freeControlMessages(sub); _cleanupOwnDispatcher(sub); - NATS_FREE(sub->subject); NATS_FREE(sub->queue); natsCondition_Destroy(sub->drainCond); @@ -124,6 +123,7 @@ _freeSub(natsSubscription *sub) natsConn_release(sub->conn); printf("<>/<> Freeing subscription %s\n", sub->subject); + NATS_FREE(sub->subject); NATS_FREE(sub); }