Assert that we don't divide by 0 in random_testing.cc.

This is always true due to the condition function, but if we introduce a
bug that makes the condition not be applied, this causes undefined
behaviour.
This commit is contained in:
iphydf 2018-08-11 12:43:37 +00:00
parent d92c96e783
commit 3fe0551417
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9

View File

@ -299,10 +299,12 @@ int main() {
return tox_conference_get_chatlist_size(state.tox()) != 0;
},
[](Local_State *state, Random *rnd, std::mt19937 *rng) {
size_t chat_count = tox_conference_get_chatlist_size(state->tox());
assert(chat_count != 0); // Condition above.
TOX_ERR_CONFERENCE_INVITE err;
tox_conference_invite(
state->tox(), rnd->friend_selector(*rng),
state->next_invite % tox_conference_get_chatlist_size(state->tox()), &err);
state->next_invite % chat_count, &err);
state->next_invite++;
assert(err == TOX_ERR_CONFERENCE_INVITE_OK);
},