aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2018-12-16 00:39:14 +0100
committerStapleButter <thetotalworm@gmail.com>2018-12-16 00:39:14 +0100
commit4a47bd6d5374a7336f1cfbb535ffddc05c85f85b (patch)
treefd65e5129f656600a8ef948cbba8023e398e8ca2
parent502d8c3fa03cf8049ca76e3f8ec3838c884134b5 (diff)
make it even saferer
-rw-r--r--src/libui_sdl/main.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index 4f0d278..6cdfe7a 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -1575,9 +1575,17 @@ int main(int argc, char** argv)
if (argv[0][len] == '\\') break;
len--;
}
- EmuDirectory = new char[len];
- strncpy(EmuDirectory, argv[0], len);
- EmuDirectory[len] = '\0';
+ if (len > 0)
+ {
+ EmuDirectory = new char[len];
+ strncpy(EmuDirectory, argv[0], len);
+ EmuDirectory[len] = '\0';
+ }
+ else
+ {
+ EmuDirectory = new char[2];
+ strcpy(EmuDirectory, ".");
+ }
}
else
{