Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for crash on windows in ParseCommandLine() #271

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Patch for crash on windows in ParseCommandLine() #271

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments


Copy link

@SDLBugzilla SDLBugzilla commented Feb 10, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Windows (All), All

Comments on the original bug report:

On 2010-03-26 14:52:53 +0000, wrote:

If a non-console Windows SDL program has a non-quoted 0th argument followed optionally by more non-quoted arguments and then by an empty quoted argument, it will crash (attempts to dereference a NULL pointer).

In other words, something like this:
test.exe [non-quoted args] "" [...]

The fix is a one-liner in ParseCommandLine() of src/main/win32/SDL_win32_main.c.

You can test this with any non-console SDL program on windows like this:

  1. Open a console (cmd.exe)
  2. Launch the program in one of the following ways:
    program ""
    program arg1 ""
    program arg1 "" arg3

These will not cause a crash:
"program" [...]
program "arg1" ""

When a Windows program is launched from Explorer, its 0th argument seems to always be quoted, so it won't be a problem in that case.

I've tested this on Windows XP SP3 and Windows 7.

I'm hoping this one-liner patch qualifies me as a prospective GSoC 2010 student.

On 2010-03-26 14:55:29 +0000, wrote:

Created attachment 501
Patch for SDL_win32_main.c.

On 2010-03-26 14:56:57 +0000, wrote:

Sorry about the whitespace foul up there :P

On 2010-07-12 22:09:07 +0000, Sam Lantinga wrote:

This is in Mercurial, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

1 participant