raft
raft copied to clipboard
null pointer dereference on raft_periodic
call of raft_periodic with the only non-self node added causes the library to crash there:
if (1 == raft_get_num_voting_nodes(me_) &&
raft_node_is_voting(raft_get_my_node((void*)me)) &&
!raft_is_leader(me_))
raft_become_leader(me_);
because raft_get_my_node return null. null pointer check should be added.
and the same kind of issue is in raft_periodic there:
if (1 < raft_get_num_voting_nodes(me_) && raft_node_is_voting(raft_get_my_node(me_)))
raft_election_start(me_);
but I'm not sure whether we need to start election there or not in this case
Sorry for not getting back to this for a long time.
When this happens it indicates that you didn't do raft_add_node with is_self = 1 for the self node. I am considering adding an if statement check that will return -1 in this situation.