Skip to content

Commit

Permalink
read_logical_snp_obj: pass user_ctx to prevent memleak (#617)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
koujl authored Dec 20, 2024
1 parent 4bd3e12 commit 6695df2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/lib/replication/repl_dev/raft_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6695df2

Please sign in to comment.