Merge pull request #147 from KTRosenberg/master

Memory Leak Prevention
This commit is contained in:
casey langen 2017-08-07 18:39:28 -07:00 committed by GitHub
commit e2c2c28f4c
2 changed files with 8 additions and 3 deletions

View File

@ -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")

View File

@ -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 */
}
}