Skip to content

Commit

Permalink
Adds version checking before calling TCHAR_TO_WCHAR
Browse files Browse the repository at this point in the history
  • Loading branch information
slartibaartfast committed Dec 13, 2018
1 parent 078908e commit 38599ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/UnrealEnginePython/Private/PyCommandlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ int32 UPyCommandlet::Main(const FString& CommandLine)
#if PY_MAJOR_VERSION >= 3
argv[i] = (wchar_t*)malloc(PyArgv[i].Len() + 1);
#if PLATFORM_MAC || PLATFORM_LINUX
#if ENGINE_MINOR_VERSION >= 20
wcsncpy(argv[i], (const wchar_t *) TCHAR_TO_WCHAR(*PyArgv[i].ReplaceEscapedCharWithChar()), PyArgv[i].Len() + 1);
#else
wcsncpy(argv[i], *PyArgv[i].ReplaceEscapedCharWithChar(), PyArgv[i].Len() + 1);
#endif
#elif PLATFORM_ANDROID
wcsncpy(argv[i], (const wchar_t *)*PyArgv[i].ReplaceEscapedCharWithChar(), PyArgv[i].Len() + 1);
#else
Expand Down
4 changes: 4 additions & 0 deletions Source/UnrealEnginePython/Private/UnrealEnginePython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ void FUnrealEnginePythonModule::UESetupPythonInterpreter(bool verbose)
for (int32 i = 0; i < Args.Num(); i++)
{
#if PY_MAJOR_VERSION >= 3
#if ENGINE_MINOR_VERSION >= 20
argv[i] = (wchar_t *)(TCHAR_TO_WCHAR(*Args[i]));
#else
argv[i] = (wchar_t *)(*Args[i]);
#endif
#else
argv[i] = TCHAR_TO_UTF8(*Args[i]);
#endif
Expand Down

0 comments on commit 38599ea

Please sign in to comment.