From df618f08a6f1d6d8ffba7a9cba99f14180d5dae9 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 15 Jan 2024 17:15:02 +0100 Subject: [PATCH] tests: Add test for issue #661 --- testparser.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/testparser.c b/testparser.c index 8f056a22..08965b50 100644 --- a/testparser.c +++ b/testparser.c @@ -10,6 +10,26 @@ #include +static int +testStandaloneWithEncoding(void) { + xmlDocPtr doc; + const char *str = + "\n" + "\n"; + int err = 0; + + xmlResetLastError(); + + doc = xmlReadDoc(BAD_CAST str, NULL, "UTF-8", 0); + if (doc == NULL) { + fprintf(stderr, "xmlReadDoc failed\n"); + err = 1; + } + xmlFreeDoc(doc); + + return err; +} + static int testUnsupportedEncoding(void) { xmlDocPtr doc; @@ -251,6 +271,7 @@ int main(void) { int err = 0; + err |= testStandaloneWithEncoding(); err |= testUnsupportedEncoding(); #ifdef LIBXML_SAX1_ENABLED err |= testBalancedChunk();