json serialize seems to allow corrupted urf8 string, add a check when reading back to avoid crashing, ref #607
This commit is contained in:
@@ -81,6 +81,8 @@ namespace lms::db
|
||||
std::vector<std::filesystem::path> PlayListFile::getFiles() const
|
||||
{
|
||||
std::vector<std::filesystem::path> files;
|
||||
|
||||
try
|
||||
{
|
||||
Wt::Json::Object root;
|
||||
Wt::Json::parse(_entries, root);
|
||||
@@ -90,6 +92,10 @@ namespace lms::db
|
||||
for (const Wt::Json::Value& file : filesArray)
|
||||
files.push_back(static_cast<std::string>(file.toString()));
|
||||
}
|
||||
catch (const Wt::Json::ParseError& e)
|
||||
{
|
||||
LMS_LOG(DB, ERROR, "Cannot parse files saved in " << _absoluteFilePath << ": corrupted data?");
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user