diff --git a/src/strings.cpp b/src/strings.cpp --- a/src/strings.cpp +++ b/src/strings.cpp @@ -185,8 +185,16 @@ struct LanguagePack : public LanguagePac char data[]; // list of strings }; +struct LanguagePackDeleter { + void operator()(LanguagePack *langpack) + { + /* LanguagePack is in fact reinterpreted char[], we need to reinterpret it back to free it properly. */ + delete[] reinterpret_cast(langpack); + } +}; + struct LoadedLanguagePack { - std::unique_ptr langpack; + std::unique_ptr langpack; std::vector offsets; @@ -1713,7 +1721,7 @@ bool ReadLanguagePack(const LanguageMeta { /* Current language pack */ size_t len = 0; - std::unique_ptr lang_pack(reinterpret_cast(ReadFileToMem(lang->file, len, 1U << 20).release())); + std::unique_ptr lang_pack(reinterpret_cast(ReadFileToMem(lang->file, len, 1U << 20).release())); if (!lang_pack) return false; /* End of read data (+ terminating zero added in ReadFileToMem()) */