diff --git a/CMakeLists.txt b/CMakeLists.txt index c96afa915..c755cafa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,10 @@ ExternalProject_Add(taglib ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wno-unused-result -Wno-deprecated-declarations") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") +# enable for additional memory checking with fsanitize +# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -fsanitize=address,undefined") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") if (${LINK_STATICALLY} MATCHES "true") diff --git a/src/core/i18n/Locale.cpp b/src/core/i18n/Locale.cpp index 651c06c5f..8d8b95a81 100644 --- a/src/core/i18n/Locale.cpp +++ b/src/core/i18n/Locale.cpp @@ -55,9 +55,11 @@ static nlohmann::json loadLocaleData(const std::string& fn) { char* bytes = nullptr; int count = 0; - if (FileToByteArray(fn, &bytes, count, true)) { + if (FileToByteArray(fn, &bytes, count, true) == true) { try { - return nlohmann::json::parse(bytes); + nlohmann::json localeData = nlohmann::json::parse(bytes); + free(bytes); + return localeData; } catch (...) { } @@ -180,4 +182,4 @@ int Locale::Dimension(const char* key, int defaultValue) { } return defaultValue; /* not found anywhere */ -} \ No newline at end of file +}