Skip to content

Commit cdc1720

Browse files
committed
Fix a comparison with garbage in Raft update processing code.
1 parent cc5f0f3 commit cdc1720

File tree

1 file changed

+2
-2
lines changed
  • contrib/raftable/raft/src

1 file changed

+2
-2
lines changed

contrib/raftable/raft/src/raft.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,8 @@ static void raft_handle_update(raft_t r, raft_msg_update_t *m) {
814814

815815
if (!m->empty && !m->snapshot && !raft_appendable(r, m->previndex, m->prevterm)) goto finish;
816816

817-
if (reply.progress.entries > 0) {
818-
reply.term = RAFT_LOG(r, reply.progress.entries - 1).term;
817+
if (RAFT_LOG_LAST_INDEX(r) >= 0) {
818+
reply.term = RAFT_LOG(r, RAFT_LOG_LAST_INDEX(r)).term;
819819
} else {
820820
reply.term = -1;
821821
}

0 commit comments

Comments
 (0)