From 74fc32586b9d28b9e9d921ef6b2bb95570f08048 Mon Sep 17 00:00:00 2001 From: Jean-Francois Moine Date: Mon, 3 Aug 2020 19:40:55 +0200 Subject: [PATCH] fix: memory corruption when error in %%staves/%%score Issue #76. --- parse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/parse.c b/parse.c index ef30b84..b129098 100644 --- a/parse.c +++ b/parse.c @@ -2321,6 +2321,11 @@ static void get_staves(struct SYMBOL *s) struct staff_s *p_staff, staves[MAXVOICE]; int i, flags, voice, staff, range, dup_voice, maxtime; + memset(staves, 0, sizeof staves); + parse_staves(s, staves); + if (staves[0].voice < 0) // if error + return; + voice_compress(); voice_dup(); @@ -2376,9 +2381,6 @@ static void get_staves(struct SYMBOL *s) } staves_found = maxtime; - memset(staves, 0, sizeof staves); - parse_staves(s, staves); - /* initialize the voices */ for (voice = 0, p_voice = voice_tb; voice < MAXVOICE;