-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Cast LibXML::Doc* to LibXML::Node*
#16412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Urgh, I wish a linter would notice "always true" and "always false" comparisons and warn about them.
Thank you @toddsundsted 🙇
|
This is an easy trap. I'm wondering if |
Sorry! Got careless. |
|
ugh again :-( this is the last time, I swear! |
LibXML.xmlFreeNode(node)on line 60 is never called becausenode.value.docis aLibXML::Doc*not aLibXML::Node*and so the comparison always evaluates tofalse. The equality method inComparableonly kicks in if the receiver and the one parameter are the same type. This PR castsdocto the correct type of the comparison.The following spec demonstrates the problem. If you adjust the number of iterations, the memory allocated scales linearly with iterations and never plateaus. Unlinking nodes by iterating over children and xpath nodes both demonstrate the problem.