Fix executable name generation under QEMU (#347)

Closes #346
This commit is contained in:
Paul Kulchenko 2022-03-04 17:49:43 -08:00 committed by GitHub
parent d938b89f4f
commit db6152e21d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -78,10 +78,9 @@ static textstartup void GetProgramExecutableName(char executable[SIZE],
char *p) {
char *t;
size_t m;
ssize_t n;
int cmd[4];
ssize_t n = 0;
if (IsWindows() && GetNtExePath(executable)) return;
n = 0;
if (fileexists(p)) {
if (!_isabspath(p)) {
if (getcwd(executable, SIZE - 1)) {
@ -111,6 +110,7 @@ static textstartup void GetProgramExecutableName(char executable[SIZE],
return;
}
}
if (n < 0) n = 0;
for (; *p; ++p) {
if (n + 1 < SIZE) {
executable[n++] = *p;