shithub: orca

Download patch

ref: d6258dbcac47ea0c5da247a4408331a2c20addc0
parent: 985a2da33ed518eabc548cca8ebcb9085599291f
author: cancel <cancel@cancel.fm>
date: Sat Jan 12 07:52:01 EST 2019

Fix incorrect buffer capacity check for sustained notes add

--- a/osc_out.c
+++ b/osc_out.c
@@ -177,8 +177,9 @@
   Usz count = sl->count;
   Usz cap = sl->capacity;
   Usz rem = count + added_count;
-  if (cap < rem) {
-    cap = rem < 16 ? 16 : orca_round_up_power2(rem);
+  Usz needed_cap = rem + added_count;
+  if (cap < needed_cap) {
+    cap = needed_cap < 16 ? 16 : orca_round_up_power2(needed_cap);
     buffer = realloc(buffer, cap * sizeof(Susnote));
     sl->capacity = cap;
     sl->buffer = buffer;