Skip to content

Commit c5ea7ab

Browse files
committed
Improve memory deallocation for merge_text_nodes
Lexbor backend
1 parent 26a7908 commit c5ea7ab

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

selectolax/lexbor/node.pxi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,11 @@ cdef class LexborNode:
518518
combined = (<bytes>left_text[:left_length]) + (<bytes>right_text[:right_length])
519519
lxb_dom_node_text_content_set(node, combined, len(combined))
520520
lxb_dom_node_remove(node.prev)
521-
522-
lxb_dom_document_destroy_text_noi(self.node.owner_document, left_text)
523-
lxb_dom_document_destroy_text_noi(self.node.owner_document, right_text)
521+
522+
if left_text is not NULL:
523+
lxb_dom_document_destroy_text_noi(self.node.owner_document, left_text)
524+
if right_text is not NULL:
525+
lxb_dom_document_destroy_text_noi(self.node.owner_document, right_text)
524526

525527
if node.first_child:
526528
LexborNode.new(node, self.parser).merge_text_nodes()

0 commit comments

Comments
 (0)