From db170cc56926bc9d0c71678a1d6a1792860e9204 Mon Sep 17 00:00:00 2001 From: Gryffindor <838492657@qq.com> Date: Mon, 1 Feb 2021 17:00:06 +0800 Subject: [PATCH] fix potential null entry reference --- src/raft_log.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/raft_log.c b/src/raft_log.c index 2188629b..433b15d1 100644 --- a/src/raft_log.c +++ b/src/raft_log.c @@ -150,6 +150,9 @@ int log_append_entry(log_t* me_, raft_entry_t* ety) return e; memcpy(&me->entries[me->back], ety, sizeof(raft_entry_t)); + /** copy the data buf */ + me->entries[me->back].data.buf = malloc(ety->data.len); + memcpy(me->entries[me->back].data.buf, ety->data.buf, ety->data.len); if (me->cb && me->cb->log_offer) {