Skip to content

Commit

Permalink
validate the value of the index attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Mar 13, 2024
1 parent 7ffac43 commit 71e9bdd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions six/modules/c++/six.sidd/source/DerivedXMLParser300.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,18 @@ void DerivedXMLParser300::parseJ2KCompression(const xml::lite::Element& j2kElem,

for (size_t ii = 0; ii < layerElems.size(); ++ii)
{
// In SIDD 3.0, the `index` attribute type changed from `positiveInteger` to `nonNegativeInteger`
// (matching C-style indexing). Since we had a problem with this, use the opportunity to
// validate the `index` value.
const auto& attributes = layerElems[ii]->getAttributes();
std::string strIndex;
if (attributes.getValue("index", strIndex))
{
// The schema says this is required, but we might not be validating.
const size_t index = std::stoi(strIndex);
assert(ii == index); // again, we might not be validating the XML
}

parseDouble(getFirstAndOnly(layerElems[ii], "Bitrate"), j2k.layerInfo[ii].bitRate);
}
}
Expand Down

0 comments on commit 71e9bdd

Please sign in to comment.