summaryrefslogtreecommitdiff
path: root/relaxng.c
diff options
context:
space:
mode:
Diffstat (limited to 'relaxng.c')
-rw-r--r--relaxng.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/relaxng.c b/relaxng.c
index 370e314..8d88e95 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -1095,7 +1095,7 @@ xmlRelaxNGAddStates(xmlRelaxNGValidCtxtPtr ctxt,
{
int i;
- if (state == NULL) {
+ if (state == NULL || states == NULL) {
return (-1);
}
if (states->nbState >= states->maxState) {
@@ -2595,13 +2595,10 @@ xmlRelaxNGSchemaTypeCompare(void *data ATTRIBUTE_UNUSED,
}
ret = xmlSchemaValPredefTypeNode(typ, value2, &res2, ctxt2);
if (ret != 0) {
- if ((comp1 == NULL) && (res1 != NULL))
+ if (res1 != (xmlSchemaValPtr) comp1)
xmlSchemaFreeValue(res1);
return (-1);
}
- if (res1 == NULL) {
- return (-1);
- }
ret = xmlSchemaCompareValues(res1, res2);
if (res1 != (xmlSchemaValPtr) comp1)
xmlSchemaFreeValue(res1);
@@ -6603,7 +6600,7 @@ xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes)
}
/*
- * Apply 4.17 mergingd rules to defines and starts
+ * Apply 4.17 merging rules to defines and starts
*/
xmlRelaxNGCombineStart(ctxt, ret);
if (ret->defs != NULL) {
@@ -6655,12 +6652,17 @@ xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
ctxt->define = NULL;
if (IS_RELAXNG(node, "grammar")) {
schema->topgrammar = xmlRelaxNGParseGrammar(ctxt, node->children);
+ if (schema->topgrammar == NULL) {
+ xmlRelaxNGFree(schema);
+ return (NULL);
+ }
} else {
xmlRelaxNGGrammarPtr tmp, ret;
schema->topgrammar = ret = xmlRelaxNGNewGrammar(ctxt);
if (schema->topgrammar == NULL) {
- return (schema);
+ xmlRelaxNGFree(schema);
+ return (NULL);
}
/*
* Link the new grammar in the tree
@@ -7317,7 +7319,7 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
}
}
/*
- * Thisd is not an else since "include" is transformed
+ * This is not an else since "include" is transformed
* into a div
*/
if (xmlStrEqual(cur->name, BAD_CAST "div")) {
@@ -7346,13 +7348,13 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
if (ns != NULL)
xmlFree(ns);
/*
- * Since we are about to delete cur, if it's nsDef is non-NULL we
+ * Since we are about to delete cur, if its nsDef is non-NULL we
* need to preserve it (it contains the ns definitions for the
* children we just moved). We'll just stick it on to the end
* of cur->parent's list, since it's never going to be re-serialized
* (bug 143738).
*/
- if (cur->nsDef != NULL) {
+ if ((cur->nsDef != NULL) && (cur->parent != NULL)) {
xmlNsPtr parDef = (xmlNsPtr)&cur->parent->nsDef;
while (parDef->next != NULL)
parDef = parDef->next;
@@ -7370,7 +7372,8 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
else if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE)) {
if (IS_BLANK_NODE(cur)) {
- if (cur->parent->type == XML_ELEMENT_NODE) {
+ if ((cur->parent != NULL) &&
+ (cur->parent->type == XML_ELEMENT_NODE)) {
if ((!xmlStrEqual(cur->parent->name, BAD_CAST "value"))
&&
(!xmlStrEqual
@@ -9050,6 +9053,19 @@ xmlRelaxNGAttributeMatch(xmlRelaxNGValidCtxtPtr ctxt,
return (ret);
list = list->next;
}
+ } else if (define->type == XML_RELAXNG_CHOICE) {
+ xmlRelaxNGDefinePtr list;
+
+ list = define->nameClass;
+ while (list != NULL) {
+ ret = xmlRelaxNGAttributeMatch(ctxt, list, prop);
+ if (ret == 1)
+ return (1);
+ if (ret < 0)
+ return (ret);
+ list = list->next;
+ }
+ return (0);
} else {
TODO}
return (1);
@@ -9409,6 +9425,10 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
oldstate = ctxt->state;
for (i = 0; i < nbgroups; i++) {
ctxt->state = xmlRelaxNGCopyValidState(ctxt, oldstate);
+ if (ctxt->state == NULL) {
+ ret = -1;
+ break;
+ }
group = partitions->groups[i];
if (lasts[i] != NULL) {
last = lasts[i]->next;