fix memory overrun

This commit is contained in:
Richard Frith-Macdonald 2020-10-14 11:46:52 +01:00
parent daa3095872
commit 020b2cef7e

View file

@ -178,7 +178,7 @@ static unsigned throttleAt = 12;
* start a new recording period.
*/
base = now;
memset(counts, '\0', 60 * 8);
memset(counts, '\0', 60 * sizeof(*counts));
slot = 0;
}
else if (slot > 59)
@ -188,8 +188,8 @@ static unsigned throttleAt = 12;
/* The recording period started over an hour ago, so we must adjust
* it forward so that the current time is in its 59th minute.
*/
memmove(counts, counts + (60 - move), move * 8);
memset(counts + move, '\0', (60 - move) * 8);
memmove(counts, counts + (60 - move), move * sizeof(*counts));
memset(counts + move, '\0', (60 - move) * sizeof(*counts));
base += move * 60;
slot = 59;
}