Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libxml2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
69
Issues
69
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
libxml2
Commits
0762c9b6
Commit
0762c9b6
authored
Sep 23, 2019
by
Nick Wellnhofer
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make xmlFreeNodeList non-recursive
Avoid call stack overflow when freeing deeply nested documents.
parent
62150ed2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
tree.c
tree.c
+21
-5
No files found.
tree.c
View file @
0762c9b6
...
...
@@ -3664,7 +3664,9 @@ xmlNextElementSibling(xmlNodePtr node) {
void
xmlFreeNodeList
(
xmlNodePtr
cur
)
{
xmlNodePtr
next
;
xmlNodePtr
parent
;
xmlDictPtr
dict
=
NULL
;
size_t
depth
=
0
;
if
(
cur
==
NULL
)
return
;
if
(
cur
->
type
==
XML_NAMESPACE_DECL
)
{
...
...
@@ -3680,16 +3682,21 @@ xmlFreeNodeList(xmlNodePtr cur) {
return
;
}
if
(
cur
->
doc
!=
NULL
)
dict
=
cur
->
doc
->
dict
;
while
(
cur
!=
NULL
)
{
while
(
1
)
{
while
((
cur
->
children
!=
NULL
)
&&
(
cur
->
type
!=
XML_DTD_NODE
)
&&
(
cur
->
type
!=
XML_ENTITY_REF_NODE
))
{
cur
=
cur
->
children
;
depth
+=
1
;
}
next
=
cur
->
next
;
parent
=
cur
->
parent
;
if
(
cur
->
type
!=
XML_DTD_NODE
)
{
if
((
__xmlRegisterCallbacks
)
&&
(
xmlDeregisterNodeDefaultValue
))
xmlDeregisterNodeDefaultValue
(
cur
);
if
((
cur
->
children
!=
NULL
)
&&
(
cur
->
type
!=
XML_ENTITY_REF_NODE
))
xmlFreeNodeList
(
cur
->
children
);
if
(((
cur
->
type
==
XML_ELEMENT_NODE
)
||
(
cur
->
type
==
XML_XINCLUDE_START
)
||
(
cur
->
type
==
XML_XINCLUDE_END
))
&&
...
...
@@ -3720,7 +3727,16 @@ xmlFreeNodeList(xmlNodePtr cur) {
DICT_FREE
(
cur
->
name
)
xmlFree
(
cur
);
}
cur
=
next
;
if
(
next
!=
NULL
)
{
cur
=
next
;
}
else
{
if
((
depth
==
0
)
||
(
parent
==
NULL
))
break
;
depth
-=
1
;
cur
=
parent
;
cur
->
children
=
NULL
;
}
}
}
...
...
Jan Pokorný
@jpokorny
mentioned in issue
#132 (closed)
·
Dec 05, 2019
mentioned in issue
#132 (closed)
mentioned in issue #132
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment