From a2e8c7f6384082318530ecd886599db2e5c67518 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Thu, 16 Mar 2017 18:02:32 +0300 Subject: [PATCH] Do not fail if locale is not supported --- runtime/src/main/cpp/Runtime.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/runtime/src/main/cpp/Runtime.cpp b/runtime/src/main/cpp/Runtime.cpp index 7d6bb6bffdd..963ffb547d9 100644 --- a/runtime/src/main/cpp/Runtime.cpp +++ b/runtime/src/main/cpp/Runtime.cpp @@ -1,4 +1,5 @@ #include +#include #include "Runtime.h" @@ -39,7 +40,7 @@ void AppendToInitializersTail(struct InitNode *next) { RuntimeState* InitRuntime() { // Set Unicode locale, otherwise towlower() and friends do not work properly. if (setlocale(LC_CTYPE, "en_US.UTF-8") == nullptr) { - return nullptr; + fprintf(stderr, "Cannot set locale, string ops may suffer\n"); } RuntimeState* result = new RuntimeState(); result->memoryState = InitMemory(); @@ -49,8 +50,10 @@ RuntimeState* InitRuntime() { } void DeinitRuntime(RuntimeState* state) { - DeinitMemory(state->memoryState); - delete state; + if (state != nullptr) { + DeinitMemory(state->memoryState); + delete state; + } } #ifdef __cplusplus