summaryrefslogtreecommitdiff
path: root/src/xmlpatterns/schema
diff options
context:
space:
mode:
authorMark Shroyer <code@markshroyer.com>2013-09-26 02:01:21 -0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-02 21:53:46 +0200
commit3c63cedb5d3defd831eb2d8bfdeb883121737ef3 (patch)
tree84e2ff50c2ad26ca7ed188484cb21cb2f666cf80 /src/xmlpatterns/schema
parent11b150d935ebdd422e3d3edb698f2e08c45e2229 (diff)
downloadqtxmlpatterns-3c63cedb5d3defd831eb2d8bfdeb883121737ef3.tar.gz
Fix undefined behavior validating XSD substitution groups
A bug in XSD substitution group validation would result in an invalid cast of SchemaType::Ptr to XsdComplexType::Ptr, in which case evaluating complexType->prohibitedSubstitutions() exhibited undefined behavior. In practice this caused validation against XSD schemas containing substitution groups to fail on some machines, where ORing the checkSet mask against out of bounds memory could cause the function XsdSchemaHelper::substitutionGroupOkTransitive() to return a false negative. Minus the bug fix, the regression test added in this commit failed on (at least) Linux ARM when compiled with the Linaro toolchain 2013.01 g++ 4.7, with flags -marm -mcpu=cortex-a8 -O2. However, it did not fail on a Linux amd64 machine prior to the bug fix. Change-Id: Idd060a941a3bc0620f1fcc903375e43022bdcbdc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/xmlpatterns/schema')
-rw-r--r--src/xmlpatterns/schema/qxsdschemahelper.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/xmlpatterns/schema/qxsdschemahelper.cpp b/src/xmlpatterns/schema/qxsdschemahelper.cpp
index 8072d92..c5e0ee0 100644
--- a/src/xmlpatterns/schema/qxsdschemahelper.cpp
+++ b/src/xmlpatterns/schema/qxsdschemahelper.cpp
@@ -635,7 +635,7 @@ bool XsdSchemaHelper::substitutionGroupOkTransitive(const XsdElement::Ptr &head,
NamedSchemaComponent::BlockingConstraints checkSet(blockSet);
checkSet |= head->disallowedSubstitutions();
- if (head->type()->isComplexType()) {
+ if (head->type()->isComplexType() && head->type()->isDefinedBySchema()) {
const XsdComplexType::Ptr complexType(head->type());
checkSet |= complexType->prohibitedSubstitutions();
}