Commit 76d36458 authored by Daniel Veillard's avatar Daniel Veillard

Fixing assorted potential problems raised by scan

* encoding.c parser.c relaxng.c runsuite.c tree.c xmlreader.c
  xmlschemas.c: nothing really serious but better safe than sorry
parent 15495610
......@@ -1414,7 +1414,7 @@ xmlCleanupCharEncodingHandlers(void) {
void
xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
if (handlers == NULL) xmlInitCharEncodingHandlers();
if (handler == NULL) {
if ((handler == NULL) || (handlers == NULL)) {
xmlEncodingErr(XML_I18N_NO_HANDLER,
"xmlRegisterCharEncodingHandler: NULL handler !\n", NULL);
return;
......
......@@ -250,14 +250,15 @@ xmlErrAttributeDup(xmlParserCtxtPtr ctxt, const xmlChar * prefix,
return;
if (ctxt != NULL)
ctxt->errNo = XML_ERR_ATTRIBUTE_REDEFINED;
if (prefix == NULL)
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
ctxt->errNo, XML_ERR_FATAL, NULL, 0,
XML_ERR_ATTRIBUTE_REDEFINED, XML_ERR_FATAL, NULL, 0,
(const char *) localname, NULL, NULL, 0, 0,
"Attribute %s redefined\n", localname);
else
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
ctxt->errNo, XML_ERR_FATAL, NULL, 0,
XML_ERR_ATTRIBUTE_REDEFINED, XML_ERR_FATAL, NULL, 0,
(const char *) prefix, (const char *) localname,
NULL, 0, 0, "Attribute %s:%s redefined\n", prefix,
localname);
......@@ -555,14 +556,20 @@ xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
schannel = ctxt->sax->serror;
}
__xmlRaiseError(schannel,
if (ctxt != NULL) {
__xmlRaiseError(schannel,
ctxt->vctxt.error, ctxt->vctxt.userData,
ctxt, NULL, XML_FROM_DTD, error,
XML_ERR_ERROR, NULL, 0, (const char *) str1,
(const char *) str2, NULL, 0, 0,
msg, (const char *) str1, (const char *) str2);
if (ctxt != NULL) {
ctxt->valid = 0;
} else {
__xmlRaiseError(schannel, NULL, NULL,
ctxt, NULL, XML_FROM_DTD, error,
XML_ERR_ERROR, NULL, 0, (const char *) str1,
(const char *) str2, NULL, 0, 0,
msg, (const char *) str1, (const char *) str2);
}
}
......@@ -12500,7 +12507,9 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
* Record in the parent context the number of entities replacement
* done when parsing that reference.
*/
oldctxt->nbentities += ctxt->nbentities;
if (oldctxt != NULL)
oldctxt->nbentities += ctxt->nbentities;
/*
* Also record the size of the entity parsed
*/
......
......@@ -5363,7 +5363,7 @@ xmlRelaxNGParseNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node,
} else {
xmlRngPErr(ctxt, node, XML_RNGP_CHOICE_CONTENT,
"expecting name, anyName, nsName or choice : got %s\n",
node->name, NULL);
(node == NULL ? 'nothing' : node->name), NULL);
return (NULL);
}
if (ret != def) {
......@@ -9442,7 +9442,11 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGFreeStates(ctxt, ctxt->states);
ctxt->states = NULL;
if (found == 0) {
VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, cur->name);
if (cur == NULL) {
VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, 'noname');
} else {
VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, cur->name);
}
ret = -1;
ctxt->state = oldstate;
goto done;
......
......@@ -307,7 +307,7 @@ getString(xmlNodePtr cur, const char *xpath) {
* *
************************************************************************/
static int
static int
xsdIncorectTestCase(xmlNodePtr cur) {
xmlNodePtr test;
xmlBufferPtr buf;
......@@ -319,7 +319,7 @@ xsdIncorectTestCase(xmlNodePtr cur) {
if (cur == NULL) {
return(0);
}
test = getNext(cur, "./*");
if (test == NULL) {
test_log("Failed to find test in correct line %ld\n",
......
......@@ -1801,7 +1801,7 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
if (cur == NULL) {
if ((eatname == 1) &&
((node->doc == NULL) ||
((node == NULL) || (node->doc == NULL) ||
(!(xmlDictOwns(node->doc->dict, name)))))
xmlFree((xmlChar *) name);
xmlTreeErrMemory("building attribute");
......@@ -1861,8 +1861,8 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
}
}
if ((value != NULL) &&
(xmlIsID((node == NULL) ? NULL : node->doc, node, cur) == 1))
if ((value != NULL) && (node != NULL) &&
(xmlIsID(node->doc, node, cur) == 1))
xmlAddID(NULL, node->doc, value, cur);
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
......@@ -7779,8 +7779,11 @@ xmlDOMWrapStoreNs(xmlDocPtr doc,
}
}
/* Create. */
ns->next = xmlNewNs(NULL, nsName, prefix);
return (ns->next);
if (ns != NULL) {
ns->next = xmlNewNs(NULL, nsName, prefix);
return (ns->next);
}
return(NULL);
}
/*
......
......@@ -1436,7 +1436,7 @@ get_next_node:
/*
* Cleanup of the old node
*/
if ((reader->preserves == 0) &&
if ((oldnode != NULL) && (reader->preserves == 0) &&
#ifdef LIBXML_XINCLUDE_ENABLED
(reader->in_xinclude == 0) &&
#endif
......
......@@ -6797,7 +6797,7 @@ xmlSchemaParseWildcardNs(xmlSchemaParserCtxtPtr ctxt,
tmp->next = NULL;
if (wildc->nsSet == NULL)
wildc->nsSet = tmp;
else
else if (lastNs != NULL)
lastNs->next = tmp;
lastNs = tmp;
}
......@@ -23721,12 +23721,14 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
parBind->dupls = bind->dupls;
bind->dupls = NULL;
}
if (*parTable == NULL)
*parTable = parBind;
else {
parBind->next = *parTable;
*parTable = parBind;
}
if (parTable != NULL) {
if (*parTable == NULL)
*parTable = parBind;
else {
parBind->next = *parTable;
*parTable = parBind;
}
}
}
next_binding:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment