Skip to content

Fix off-by-one error in syswin.inc:setup_arguments.

Rika requested to merge runewalsh/source:argv into main

There was an off-by-one error in !643 (merged) 😥 because when parsing the command line, character is read and pointer is immediately advanced (I wouldn’t do that, but that’s how it was done originally, and I didn’t change that so I wouldn’t accidentally break the behavior in extreme cases of "a"""b), so if you want to remember the position, you need cmdLine - 1 rather than cmdLine.

The error cancels out unless your DefaultSystemCodePage allows multibyte sequences, and the first character of the second argument (first argument is completely skipped) needs such a sequence. This example copypastes setup_arguments and sets up the bad case: argv.pas, run it under -gh: Use heaptrace unit, you should get Marked memory at XXX invalid.

Merge request reports