From bcbee613e414f5449cd0ed3e722e35706db7cf28 Mon Sep 17 00:00:00 2001 From: mu <59917266+4eUeP@users.noreply.github.com> Date: Mon, 22 Jan 2024 21:55:26 -0800 Subject: [PATCH] fix(kafka cpp): do not free NUL stable_ptr (#1747) --- hstream-kafka/cbits/hs_kafka_server.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hstream-kafka/cbits/hs_kafka_server.cpp b/hstream-kafka/cbits/hs_kafka_server.cpp index 290ad40c7..ddd8f102b 100644 --- a/hstream-kafka/cbits/hs_kafka_server.cpp +++ b/hstream-kafka/cbits/hs_kafka_server.cpp @@ -55,9 +55,12 @@ class ServerHandler : public HandlerAdapter> { HsStablePtr sp_; void onClientExit() { - hs_free_stable_ptr(sp_); - // Make sure the haskell land does not use the freed stable pointer - sp_ = nullptr; + // FIXME: lock guard here? + if (sp_ != nullptr) { + hs_free_stable_ptr(sp_); + // Make sure the haskell land does not use the freed stable pointer + sp_ = nullptr; + } } };