DavidKinder / Windows-Frotz

Z-code interpreter for Windows, based on Stefan Jokisch's Frotz interpreter core.
http://www.davidkinder.co.uk/frotz.html
GNU General Public License v2.0
58 stars 12 forks source link

@output_stream handled improperly #19

Closed DavidKinder closed 3 years ago

DavidKinder commented 3 years ago

Taken from https://gitlab.com/DavidGriffith/frotz/-/issues/1:

This was sent in by David Fillmore today: According to the Z-Machine specification: "In Version 6, a width field may optionally be given: if this is non-zero, text will then be justified as if it were in the window with that number (if width is positive) or a box -width pixels wide (if negative). Then the table will contain not ordinary text but formatted text: see print_form." Frotz, on the other hand, tries to get the width of a window of number -width if the value is <= 0, but passes the width value through directly if it is positive. This results in the interpreter crashing with an "Illegal window" error if the width value is less than -7. Sample Inform6 code tickling this bug:

Switches v6;
Array formatted table 50;

[ main x;
  @output_stream 3 formatted (-30);  ! Frotz treats this as a window number and crashes.
  print "ooh, hello there^boy^how are you";
  @output_stream (-3);
  @print_form formatted;
  @read_char 1 -> x;
];

See also https://intfiction.org/t/output-stream-3-with-width-parameter-causes-interpreter-halt-z6/50659

DavidKinder commented 3 years ago

This was actually fixed some time ago, by acd31748f68e24c88348e11ad0ad8ebc42a71a3d.