shithub: orca

Download patch

ref: e53c7a15c38644dd5b3150facbfefaef1de47e27
parent: 058d5ab589fda33f3d6b8ed841e2496d1fe06090
parent: 2b722c0f67545d6a94f12d1bc132509d46937aaf
author: cancel <cancel@cancel.fm>
date: Fri Sep 13 05:16:16 EDT 2019

Merge branch 'classic'

--- a/bank.c
+++ b/bank.c
@@ -20,7 +20,10 @@
 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;
   }