Skip to content

Commit

Permalink
fix: crash when staff width too small
Browse files Browse the repository at this point in the history
Issue #74.
  • Loading branch information
moinejf committed Jul 25, 2020
1 parent 8ce5f3a commit 83c0bb3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions format.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,29 @@ void interpret_fmt_line(char *w, /* keyword */
case FORMAT_U:
*((float *) fd->v) = scan_u(p, fd->subtype);
switch (fd->subtype) {
case 1:
if (strcmp(fd->name, "rightmargin") != 0
&& strcmp(fd->name, "leftmargin") != 0)
break;
staffwidth = cfmt.pagewidth -
cfmt.leftmargin -
cfmt.rightmargin;
if (staffwidth > 100)
break;
error(1, NULL, "'staffwidth' too small\n");
staffwidth = 100;
if (fd->name[0] == 'r')
cfmt.rightmargin = cfmt.pagewidth -
cfmt.leftmargin - staffwidth;
else
cfmt.leftmargin = cfmt.pagewidth -
cfmt.rightmargin - staffwidth;
break;
case 2: /* staffwidth */
if (staffwidth < 100) {
error(1, NULL, "'staffwidth' too small\n");
break;
}
f = (cfmt.landscape ? cfmt.pageheight : cfmt.pagewidth)
- staffwidth - cfmt.leftmargin;
if (f < 0)
Expand Down

0 comments on commit 83c0bb3

Please sign in to comment.