diff options
| author | StapleButter <thetotalworm@gmail.com> | 2018-12-16 00:39:14 +0100 | 
|---|---|---|
| committer | StapleButter <thetotalworm@gmail.com> | 2018-12-16 00:39:14 +0100 | 
| commit | 4a47bd6d5374a7336f1cfbb535ffddc05c85f85b (patch) | |
| tree | fd65e5129f656600a8ef948cbba8023e398e8ca2 | |
| parent | 502d8c3fa03cf8049ca76e3f8ec3838c884134b5 (diff) | |
make it even saferer
| -rw-r--r-- | src/libui_sdl/main.cpp | 14 | 
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      { |