]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove unnecessary complication around xmlParseBalancedChunkMemory.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 29 Jul 2025 16:47:19 +0000 (12:47 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 29 Jul 2025 16:47:19 +0000 (12:47 -0400)
When I prepared 71c0921b6 et al yesterday, I was thinking that the
logic involving explicitly freeing the node_list output was still
needed to dodge leakage bugs in libxml2.  But I was misremembering:
we introduced that only because with early 2.13.x releases we could
not trust xmlParseBalancedChunkMemory's result code, so we had to
look to see if a node list was returned or not.  There's no reason
to believe that xmlParseBalancedChunkMemory will fail to clean up
the node list when required, so simplify.  (This essentially
completes reverting all the non-cosmetic changes in 6082b3d5d.)

Reported-by: Jim Jones <jim.jones@uni-muenster.de>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/997668.1753802857@sss.pgh.pa.us
Backpatch-through: 13

src/backend/utils/adt/xml.c

index 28af16fe93eea226a9ab42b3bd03463fe28a0db7..cf793b6fc6698a4919d8620a6afb0b3e2e81345c 100644 (file)
@@ -1883,24 +1883,16 @@ xml_parse(text *data, XmlOptionType xmloption_arg,
                        /* allow empty content */
                        if (*(utf8string + count))
                        {
-                               xmlNodePtr      node_list = NULL;
-
                                res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0,
                                                                                                           utf8string + count,
-                                                                                                          &node_list);
+                                                                                                          parsed_nodes);
                                if (res_code != 0 || xmlerrcxt->err_occurred)
                                {
                                        xml_errsave(escontext, xmlerrcxt,
                                                                ERRCODE_INVALID_XML_CONTENT,
                                                                "invalid XML content");
-                                       xmlFreeNodeList(node_list);
                                        goto fail;
                                }
-
-                               if (parsed_nodes != NULL)
-                                       *parsed_nodes = node_list;
-                               else
-                                       xmlFreeNodeList(node_list);
                        }
                }