utils: Validate svg cursor metadata better
Metadata array must contain at least one item.
This commit is contained in:
parent
5cff8cd2d1
commit
e03fb08bcc
1 changed files with 19 additions and 15 deletions
|
@ -73,9 +73,16 @@ std::optional<SvgCursorMetaData> SvgCursorMetaData::parse(const QString &filePat
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
QList<SvgCursorMetaDataEntry> entries;
|
||||
if (document.isArray()) {
|
||||
if (!document.isArray()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const QJsonArray array = document.array();
|
||||
if (array.isEmpty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
QList<SvgCursorMetaDataEntry> entries;
|
||||
for (int i = 0; i < array.size(); ++i) {
|
||||
const QJsonValue element = array.at(i);
|
||||
if (!element.isObject()) {
|
||||
|
@ -87,9 +94,6 @@ std::optional<SvgCursorMetaData> SvgCursorMetaData::parse(const QString &filePat
|
|||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return SvgCursorMetaData{
|
||||
.entries = entries,
|
||||
|
|
Loading…
Reference in a new issue