fix crash when reading .po files

You may _never_ use the std:: file io functions
in wesnoth since they only support acii characters
on windows in filenames. We have fixed this many
times already but apparently the person that added
.po file support wasn't aware of this issue.

fixes #4965
This commit is contained in:
gfgtdf 2020-06-23 17:35:11 +02:00
parent 0f2e4f69f7
commit 9b380c6e20

View file

@ -131,12 +131,11 @@ namespace
if(!filesystem::file_exists(path)) {
continue;
}
std::ifstream po_file;
po_file.exceptions(std::ios::badbit);
LOG_G << "Loading language file from " << path << '\n';
try {
po_file.open(path);
const po_catalog& cat = po_catalog::from_istream(po_file);
filesystem::scoped_istream po_file = filesystem::istream_file(path);
po_file->exceptions(std::ios::badbit);
const po_catalog& cat = po_catalog::from_istream(*po_file);
extra_messages_.emplace(get_base().domain(domain), cat);
} catch(const spirit_po::catalog_exception& e) {
throw_po_error(lang_name_long, domain, e.what());