Skip to content

Commit

Permalink
Fix crash in igmp_start_timer (esp8266#1826)
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed May 6, 2016
1 parent f266f8a commit 0b7f8f9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tools/sdk/lwip/src/core/ipv4/igmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,22 @@ static void
igmp_start_timer(struct igmp_group *group, u8_t max_time)
{
/* ensure the input value is > 0 */
#ifdef LWIP_RAND
if (max_time == 0) {
max_time = 1;
}
/* ensure the random value is > 0 */
group->timer = (LWIP_RAND() % (max_time - 1)) + 1;
group->timer = (LWIP_RAND() % max_time);
if (group->timer == 0) {
group->timer = 1;
}
#else /* LWIP_RAND */
/* ATTENTION: use this only if absolutely necessary! */
group->timer = max_time / 2;
if (group->timer == 0) {
group->timer = 1;
}
#endif /* LWIP_RAND */
}

/**
Expand Down

0 comments on commit 0b7f8f9

Please sign in to comment.