1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

valid: Readd argument check in xmlAddElementDecl

Fix crashes with API fuzzer.
This commit is contained in:
Nick Wellnhofer
2025-05-27 12:19:25 +02:00
parent 78454e30e9
commit 77c583e0f7
2 changed files with 6 additions and 6 deletions

View File

@@ -38,6 +38,9 @@
#ifndef XML_DEPRECATED #ifndef XML_DEPRECATED
#define XML_DEPRECATED #define XML_DEPRECATED
#endif #endif
#ifndef XML_DEPRECATED_MEMBER
#define XML_DEPRECATED_MEMBER
#endif
#include <libxml/catalog.h> #include <libxml/catalog.h>
#include <libxml/HTMLtree.h> #include <libxml/HTMLtree.h>
@@ -2649,7 +2652,7 @@ LLVMFuzzerTestOneInput(const char *data, size_t size) {
oomReport = 0; oomReport = 0;
/* /*
* Don't reference XML_ELEMENT_TYPE_UNDEFINED dummy * Don't reference XML_ELEMENT_TYPE_UNDEFINED dummy
* declarations. * declarations which can be freed by xmlAddElementDecl.
*/ */
if (elem != NULL && elem->parent == NULL) if (elem != NULL && elem->parent == NULL)
elem = NULL; elem = NULL;

View File

@@ -1101,12 +1101,9 @@ xmlAddElementDecl(xmlValidCtxt *ctxt,
const xmlChar *localName; const xmlChar *localName;
xmlChar *prefix = NULL; xmlChar *prefix = NULL;
if (dtd == NULL) { if ((dtd == NULL) || (name == NULL) ||
(type < XML_ELEMENT_TYPE_EMPTY) || (type > XML_ELEMENT_TYPE_ELEMENT))
return(NULL); return(NULL);
}
if (name == NULL) {
return(NULL);
}
/* /*
* check if name is a QName * check if name is a QName