File tree Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,8 @@ Read `filename` and create an XML document.
139139"""
140140function readxml (filename:: AbstractString )
141141 encoding = C_NULL
142- options = 0
142+ # Do not reuse the context dictionary.
143+ options = 1 << 12
143144 doc_ptr = @check ccall (
144145 (:xmlReadFile , libxml2),
145146 Ptr{_Node},
Original file line number Diff line number Diff line change @@ -825,10 +825,12 @@ function unlink!(node::Node)
825825 Void,
826826 (Ptr{Void},),
827827 node. ptr)
828+ ccall (
829+ (:xmlSetTreeDoc , libxml2),
830+ Void,
831+ (Ptr{Void}, Ptr{Void}),
832+ node. ptr, C_NULL )
828833 update_owners! (node, node)
829- # Unlinking must remove documents as well because
830- # a node can free resources its document owns.
831- unset_documents! (node)
832834 return node
833835end
834836
@@ -874,16 +876,6 @@ function update_owners!(root, new_owner)
874876 end
875877end
876878
877- # Unset the .doc field of the `root` tree.
878- function unset_documents! (root)
879- offset = fieldoffset (_Node, 9 )
880- traverse_tree (root. ptr) do node_ptr
881- unsafe_store! (
882- convert (Ptr{UInt}, node_ptr + offset),
883- convert (UInt, C_NULL ))
884- end
885- end
886-
887879
888880# Utils
889881# -----
Original file line number Diff line number Diff line change 971971 target = firstelement (root (doc2))
972972 @test_throws ArgumentError linknext! (target, child)
973973 @test_throws ArgumentError linkprev! (target, child)
974+
975+ # Issue #28
976+ doc = readxml (joinpath (dirname (@__FILE__ ), " sample1.xml" ))
977+ unlink! (firstelement (root (doc)))
978+ # No need to check the return value because this is a bug of memory
979+ # management. Regression will be detected as a SIGABRT.
980+ @test true
974981end
975982
976983@testset " Validation" begin
You can’t perform that action at this time.
0 commit comments