Guard against known-invalid-input to avoid exception.

This commit is contained in:
casey langen 2022-12-21 15:52:23 -08:00
parent 7be532bb72
commit a1181f2f87
2 changed files with 10 additions and 3 deletions

View File

@ -304,11 +304,13 @@ bool IndexerTrack::NeedsToBeIndexed(
static int stringToInt(const std::string& str, const int defaultValue) {
try {
return std::stoi(str, 0, 10);
if (str.size()) {
return std::stoi(str, 0, 10);
}
}
catch (...) {
return defaultValue;
}
return defaultValue;
}
static int64_t writeToTracksTable(

View File

@ -146,7 +146,12 @@ static TagLib::FileRef resolveOggType(const char* uri) {
}
static bool isValidYear(const std::string& year) {
return std::stoi(year) > 0;
try {
return year.size() && std::stoi(year) > 0;
}
catch (...) {
}
return false;
}
static float toReplayGainFloat(const std::string& input) {