bk: 53d7e974DhdcT_XG61P9iwQSGNKVTg
+* [Bug 2628] 'mon_getmoremem()' relies on undefined behaviour
(4.2.7p453) 2014/07/19 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 2597] leap file loose ends (follow-up)
- uniform expiration check messages for config and timer triggered
mon_getmoremem(void)
{
mon_entry *chunk;
- mon_entry *mon;
u_int entries;
entries = (0 == mon_mem_increments)
? mru_initalloc
: mru_incalloc;
- chunk = emalloc(entries * sizeof(*chunk));
- for (mon = chunk + entries - 1; mon >= chunk; mon--)
- mon_free_entry(mon);
+ if (entries) {
+ chunk = emalloc(entries * sizeof(*chunk));
+ mru_alloc += entries;
+ for (chunk += entries; entries; entries--)
+ mon_free_entry(--chunk);
- mru_alloc += entries;
- mon_mem_increments++;
+ mon_mem_increments++;
+ }
}