From 6695df205d1b579f76a07734a9bc5c6eec2d86c4 Mon Sep 17 00:00:00 2001 From: koujl <108138320+koujl@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:59:49 +0800 Subject: [PATCH] read_logical_snp_obj: pass user_ctx to prevent memleak (#617) Ensure user_ctx is passed up to NuRaft regardless of the return value to enable the cleanup of the allocated context object. Signed-off-by: Jilong Kou --- conanfile.py | 2 +- src/lib/replication/repl_dev/raft_state_machine.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index f557e1bba..67cb2dad9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.5.28" + version = "6.5.29" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/lib/replication/repl_dev/raft_state_machine.cpp b/src/lib/replication/repl_dev/raft_state_machine.cpp index 09bd6b7ba..c8f7f118a 100644 --- a/src/lib/replication/repl_dev/raft_state_machine.cpp +++ b/src/lib/replication/repl_dev/raft_state_machine.cpp @@ -332,10 +332,9 @@ int RaftStateMachine::read_logical_snp_obj(nuraft::snapshot& s, void*& user_ctx, // Listener will read the snapshot data and we pass through the same. int ret = m_rd.m_listener->read_snapshot_obj(snp_ctx, snp_data); + user_ctx = snp_data->user_ctx; // Have to pass the user_ctx to NuRaft even if ret<0 to get it freed later if (ret < 0) return ret; - // Update user_ctx and whether is_last_obj - user_ctx = snp_data->user_ctx; is_last_obj = snp_data->is_last_obj; // We are doing a copy here.