From b098c8ad4abd72db489e7cf3808d80e67ef9d317 Mon Sep 17 00:00:00 2001 From: Chris Moore Date: Mon, 20 Feb 2023 09:08:40 -0800 Subject: [PATCH] Fix bug in tosc_reset tosc_reset was operating on offsets based on the location of the format (o->format). When it came time to adjust the marker location to a multiple of 4 bytes it adjusted that index to a multiple of 4 bytes, which gives you a location aligned relative to o->format. But the location needs aligned relative to the entire buffer. This change re-writes tosc_reset to operate entirely relative to the buffer start rather than to the start of the format. --- tinyosc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tinyosc.c b/tinyosc.c index 3bfc616969..150a16e947 100644 --- a/tinyosc.c +++ b/tinyosc.c @@ -155,10 +155,10 @@ unsigned char *tosc_getNextMidi(tosc_message *o) { } tosc_message *tosc_reset(tosc_message *o) { - int i = 0; - while (o->format[i] != '\0') ++i; + int i = o->format - o->buffer; + while (o->buffer[i] != '\0') ++i; i = (i + 4) & ~0x3; // advance to the next multiple of 4 after trailing '\0' - o->marker = o->format + i - 1; // -1 to account for ',' format prefix + o->marker = o->buffer + i; return o; }