From 5f54bac9ebfc1486c9180b581e32588ee74c59e4 Mon Sep 17 00:00:00 2001 From: David Kilzer Date: Sat, 10 Jun 2023 10:50:02 -0700 Subject: [PATCH] testapi: test_xmlSAXDefaultVersion() leaves xmlSAX2DefaultVersionValue set to 1 with LIBXML_SAX1_ENABLED Add code to save and to restore the default value of xmlSAX2DefaultVersionValue. Fixes #554. --- gentest.py | 8 ++++++++ testapi.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/gentest.py b/gentest.py index 40d963b4..16c0e379 100755 --- a/gentest.py +++ b/gentest.py @@ -205,6 +205,10 @@ extra_pre_call = { """, "xmlParserInputBufferCreateFd": "if (fd >= 0) fd = -1;", + "xmlSAXDefaultVersion": """ + { + int original_version = xmlSAXDefaultVersion(2); +""", } extra_post_call = { "xmlAddChild": @@ -261,6 +265,10 @@ extra_post_call = { "xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", "xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", "xmlDOMWrapAdoptNode": "if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}", + "xmlSAXDefaultVersion": """ + (void)xmlSAXDefaultVersion(original_version); + } +""", } modules = [] diff --git a/testapi.c b/testapi.c index 96393ade..fd3fc946 100644 --- a/testapi.c +++ b/testapi.c @@ -5300,7 +5300,14 @@ test_xmlSAXDefaultVersion(void) { mem_base = xmlMemBlocks(); version = gen_int(n_version, 0); + { + int original_version = xmlSAXDefaultVersion(2); + + ret_val = xmlSAXDefaultVersion(version); + (void)xmlSAXDefaultVersion(original_version); + } + desret_int(ret_val); call_tests++; des_int(n_version, version, 0);