mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 14:08:03 -06:00
Fix unsafe type narrowing
Appending the warning below:
qBittorrent\src\base/utils/version.h(176): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
qBittorrent\src\base/utils/version.h(185): note: see reference to function template instantiation 'std::array<T,2> Utils::Version<T,2,2>::parseList<StringsList>(const StringsList &)' being compiled
with
[
T=unsigned short,
StringsList=QList<QByteArray>
]
This commit is contained in:
@@ -173,7 +173,7 @@ namespace Utils
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
ComponentsArray res {{}};
|
ComponentsArray res {{}};
|
||||||
for (std::size_t i = 0; i < static_cast<std::size_t>(versionParts.size()); ++i) {
|
for (std::size_t i = 0; i < static_cast<std::size_t>(versionParts.size()); ++i) {
|
||||||
res[i] = static_cast<T>(versionParts[i].toInt(&ok));
|
res[i] = static_cast<T>(versionParts[static_cast<typename StringsList::size_type>(i)].toInt(&ok));
|
||||||
if (!ok)
|
if (!ok)
|
||||||
throw std::runtime_error("Can not parse version component");
|
throw std::runtime_error("Can not parse version component");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user