mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
- fixed potential crash on startup, Windows only
At least one version of Windows SDK (10.0.17134.0) has broken _pgmptr/_get_pgmptr() It points to an empty string for multi-byte character set applications GetModuleFileName() is now used instead regardless of compiler/toolchain Added extra guard against unexpected program paths to avoid crashes https://forum.zdoom.org/viewtopic.php?t=60598
This commit is contained in:
parent
751e318c4e
commit
e1e441091d
1 changed files with 7 additions and 10 deletions
|
@ -915,23 +915,20 @@ void DoMain (HINSTANCE hInstance)
|
||||||
atterm (I_Quit);
|
atterm (I_Quit);
|
||||||
|
|
||||||
// Figure out what directory the program resides in.
|
// Figure out what directory the program resides in.
|
||||||
char *program;
|
char progbuff[1024];
|
||||||
|
if (GetModuleFileName(nullptr, progbuff, sizeof progbuff) == 0)
|
||||||
#ifdef _MSC_VER
|
|
||||||
if (_get_pgmptr(&program) != 0)
|
|
||||||
{
|
{
|
||||||
I_FatalError("Could not determine program location.");
|
I_FatalError("Could not determine program location.");
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
char progbuff[1024];
|
|
||||||
GetModuleFileName(0, progbuff, sizeof(progbuff));
|
|
||||||
progbuff[1023] = '\0';
|
progbuff[1023] = '\0';
|
||||||
program = progbuff;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
char *program = progbuff;
|
||||||
progdir = program;
|
progdir = program;
|
||||||
program = progdir.LockBuffer();
|
program = progdir.LockBuffer();
|
||||||
*(strrchr(program, '\\') + 1) = '\0';
|
if (char *lastsep = strrchr(program, '\\'))
|
||||||
|
{
|
||||||
|
lastsep[1] = '\0';
|
||||||
|
}
|
||||||
FixPathSeperator(program);
|
FixPathSeperator(program);
|
||||||
progdir.Truncate((long)strlen(program));
|
progdir.Truncate((long)strlen(program));
|
||||||
progdir.UnlockBuffer();
|
progdir.UnlockBuffer();
|
||||||
|
|
Loading…
Reference in a new issue