Skip to content

Commit

Permalink
fix: memory corruption when error in %%staves/%%score
Browse files Browse the repository at this point in the history
Issue #76.
  • Loading branch information
moinejf committed Aug 3, 2020
1 parent 191fa55 commit 74fc325
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 74fc325

Please sign in to comment.