From e9be2691411179ca8030bdf44b3deecfb8f3ff7a Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Apr 2022 14:19:29 +0200 Subject: [PATCH] Fix crash in midi_latency_test `s` points to a constant string literal in the current code (which is in practice just a pointer in some read-only memory). The next line `s[2] = c;` either crashes or just gets completely removed by the compiler as it attempts to write to read-only memory. --- example-clients/midi_latency_test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example-clients/midi_latency_test.c b/example-clients/midi_latency_test.c index 1a6988c0..58138cf9 100644 --- a/example-clients/midi_latency_test.c +++ b/example-clients/midi_latency_test.c @@ -652,8 +652,7 @@ main(int argc, char **argv) break; default: { - char *s = "'- '"; - s[2] = c; + signed char s[] = {'\'', '-', c, '\'', '\0'}; die(s, "invalid switch"); } case -1: