From 2b722c0f67545d6a94f12d1bc132509d46937aaf Mon Sep 17 00:00:00 2001 From: cancel Date: Fri, 13 Sep 2019 09:14:00 +0900 Subject: [PATCH] Fix incorrect capacity adjustment in Oevent list Was capped at 16 instead of properly growing as it should have. --- bank.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bank.c b/bank.c index e358bca..b2e3d73 100644 --- a/bank.c +++ b/bank.c @@ -20,7 +20,10 @@ void oevent_list_copy(Oevent_list const* src, Oevent_list* dest) { Oevent* oevent_list_alloc_item(Oevent_list* olist) { Usz count = olist->count; if (olist->capacity == count) { - Usz capacity = count < 16 ? 16 : orca_round_up_power2(count); + // Note: no overflow check, but you're probably out of memory if this + // happens anyway. Like other uses of realloc in orca, we also don't check + // for a failed allocation. + Usz capacity = count < 16 ? 16 : orca_round_up_power2(count + 1); olist->buffer = realloc(olist->buffer, capacity * sizeof(Oevent)); olist->capacity = capacity; }