Fix use-after-free in XPath php:function argument nodes#22468
Conversation
A php:function() callback receives DOM node arguments as proxies that own the underlying libxml node. If the callback detaches such a node, the argument cleanup frees it while libxml is still evaluating the expression and still references it in the result node-set. Keep node and node-set argument proxies alive until evaluation ends, as returned nodes already are.
|
question: |
|
Conscious, yes. The return-value proxies already lived in I deliberately avoided flushing per query/evaluate: a |
When an XPath php:function() callback removes a node passed to it as an argument, the node is freed the moment the callback returns because the argument cleanup drops the only proxy holding it, while libxml still references that node in the running evaluation's node-set. The read inside xmlXPathEvalExpression() is then a use-after-free. Returned nodes are already kept alive in the registry node list for the evaluation's duration; argument node and node-set proxies now get the same treatment.