53 lines
1.6 KiB
Diff
53 lines
1.6 KiB
Diff
From 9abf22ef29816787256605a281e1413bd6063590 Mon Sep 17 00:00:00 2001
|
|
From: Stefan Behnel <stefan_ml@behnel.de>
|
|
Date: Thu, 4 Dec 2025 11:50:30 +0100
|
|
Subject: [PATCH 1/2] Fix a memory leak in the rare case of a memory allocation
|
|
error.
|
|
|
|
---
|
|
src/lxml/parser.pxi | 1 +
|
|
1 file changed, 1 insertion(+)
|
|
|
|
diff --git a/src/lxml/parser.pxi b/src/lxml/parser.pxi
|
|
index 3106e61..8d53277 100644
|
|
--- a/src/lxml/parser.pxi
|
|
+++ b/src/lxml/parser.pxi
|
|
@@ -2004,6 +2004,7 @@ cdef xmlDoc* _copyDocRoot(xmlDoc* c_doc, xmlNode* c_new_root) except NULL:
|
|
with nogil:
|
|
c_node = tree.xmlDocCopyNode(c_new_root, result, 1) # recursive
|
|
if c_node is NULL:
|
|
+ tree.xmlFreeDoc(result)
|
|
raise MemoryError()
|
|
tree.xmlDocSetRootElement(result, c_node)
|
|
_copyTail(c_new_root.next, c_node)
|
|
--
|
|
2.53.0
|
|
|
|
|
|
From 3f148c66c78cd7c010721e4b49c993b02bf0b8d5 Mon Sep 17 00:00:00 2001
|
|
From: Stefan Behnel <stefan_ml@behnel.de>
|
|
Date: Sat, 17 Jan 2026 07:21:23 +0100
|
|
Subject: [PATCH 2/2] Add missing "noexcept" to fix a memory leak.
|
|
|
|
Fixes https://bugs.launchpad.net/lxml/+bug/2138421
|
|
---
|
|
src/lxml/etree.pyx | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/src/lxml/etree.pyx b/src/lxml/etree.pyx
|
|
index 562d95e..50cb71f 100644
|
|
--- a/src/lxml/etree.pyx
|
|
+++ b/src/lxml/etree.pyx
|
|
@@ -657,7 +657,7 @@ cdef class DocInfo:
|
|
return root_name
|
|
|
|
@cython.final
|
|
- cdef tree.xmlDtd* _get_c_dtd(self):
|
|
+ cdef tree.xmlDtd* _get_c_dtd(self) noexcept:
|
|
""""Return the DTD. Create it if it does not yet exist."""
|
|
cdef xmlDoc* c_doc = self._doc._c_doc
|
|
cdef xmlNode* c_root_node
|
|
--
|
|
2.53.0
|
|
|