mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Guard against known-invalid-input to avoid exception.
This commit is contained in:
parent
7be532bb72
commit
a1181f2f87
@ -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(
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user