Check for mandatory "name" attribute in "podtype". (#3040)

This commit is contained in:
Mathias Schmid 2021-01-11 18:48:56 +01:00 committed by GitHub
parent b1c56d33ac
commit 348b2d4832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -35,6 +35,14 @@ static std::string unhandledElement(const QXmlStreamReader &xmlReader)
throw std::runtime_error(QObject::tr("line %1: Unhandled element %2").arg(xmlReader.lineNumber()).arg(xmlReader.name().toString()).toStdString());
}
static std::string mandatoryAttibuteMissing(const QXmlStreamReader &xmlReader, QString attributeName)
{
throw std::runtime_error(QObject::tr("line %1: Mandatory attribute '%2' missing in '%3'")
.arg(xmlReader.lineNumber())
.arg(attributeName)
.arg(xmlReader.name().toString()).toStdString());
}
static CppcheckLibraryData::Container loadContainer(QXmlStreamReader &xmlReader)
{
CppcheckLibraryData::Container container;
@ -232,6 +240,9 @@ static CppcheckLibraryData::PodType loadPodType(const QXmlStreamReader &xmlReade
{
CppcheckLibraryData::PodType podtype;
podtype.name = xmlReader.attributes().value("name").toString();
if (podtype.name.isEmpty()) {
mandatoryAttibuteMissing(xmlReader, "name");
}
podtype.stdtype = xmlReader.attributes().value("stdtype").toString();
podtype.size = xmlReader.attributes().value("size").toString();
podtype.sign = xmlReader.attributes().value("sign").toString();