diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-11-25 14:15:43 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-11-27 02:11:07 +0100 |
commit | 05c3a458aa8aee715dbbbcc41f4d684c1c2d10d1 (patch) | |
tree | 9626a87782a680aa242bc6082e294ac685a4a22b | |
parent | 78c0391bc722ceac7c25f1445593c86ac1006bda (diff) | |
download | libxml2-05c3a458aa8aee715dbbbcc41f4d684c1c2d10d1.tar.gz |
tests: Check that xmlInitParser doesn't allocate memory
-rw-r--r-- | parser.c | 3 | ||||
-rw-r--r-- | runtest.c | 13 |
2 files changed, 13 insertions, 3 deletions
@@ -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; @@ -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 |