summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2022-11-25 14:15:43 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2022-11-27 02:11:07 +0100
commit05c3a458aa8aee715dbbbcc41f4d684c1c2d10d1 (patch)
tree9626a87782a680aa242bc6082e294ac685a4a22b
parent78c0391bc722ceac7c25f1445593c86ac1006bda (diff)
downloadlibxml2-05c3a458aa8aee715dbbbcc41f4d684c1c2d10d1.tar.gz
tests: Check that xmlInitParser doesn't allocate memory
-rw-r--r--parser.c3
-rw-r--r--runtest.c13
2 files changed, 13 insertions, 3 deletions
diff --git a/parser.c b/parser.c
index ee64a597..7cc2a782 100644
--- a/parser.c
+++ b/parser.c
@@ -14484,6 +14484,9 @@ static int xmlParserInitialized = 0;
void
xmlInitParser(void) {
+ /*
+ * Note that the initialization code must not make memory allocations.
+ */
if (xmlParserInitialized != 0)
return;
diff --git a/runtest.c b/runtest.c
index 52c83acd..c5545fba 100644
--- a/runtest.c
+++ b/runtest.c
@@ -531,10 +531,17 @@ testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, xmlErrorPtr err) {
static void
initializeLibxml2(void) {
- xmlPedanticParserDefault(0);
-
- xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
+ /*
+ * This verifies that xmlInitParser doesn't allocate memory with
+ * xmlMalloc
+ */
+ xmlFree = NULL;
+ xmlMalloc = NULL;
+ xmlRealloc = NULL;
+ xmlMemStrdup = NULL;
xmlInitParser();
+ xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);
+ xmlPedanticParserDefault(0);
xmlSetExternalEntityLoader(testExternalEntityLoader);
xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
#ifdef LIBXML_SCHEMAS_ENABLED