mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[quickjs] Rewritten problematic fragment
There was segfault.
This commit is contained in:
parent
411492e4cb
commit
8749089352
@ -1581,19 +1581,26 @@ js_element_querySelectorAll(JSContext *ctx, JSValueConst this_val, int argc, JSV
|
|||||||
xmlpp::ustring css = str;
|
xmlpp::ustring css = str;
|
||||||
xmlpp::ustring xpath = css2xpath(css);
|
xmlpp::ustring xpath = css2xpath(css);
|
||||||
JS_FreeCString(ctx, str);
|
JS_FreeCString(ctx, str);
|
||||||
xmlpp::Node::NodeSet *elements = new(std::nothrow) xmlpp::Node::NodeSet;
|
|
||||||
|
|
||||||
if (!elements) {
|
xmlpp::Node::NodeSet elements;
|
||||||
|
xmlpp::Node::NodeSet *res = new(std::nothrow) xmlpp::Node::NodeSet;
|
||||||
|
|
||||||
|
if (!res) {
|
||||||
return JS_NULL;
|
return JS_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
*elements = el->find(xpath);
|
elements = el->find(xpath);
|
||||||
} catch (xmlpp::exception) {
|
} catch (xmlpp::exception) {}
|
||||||
}
|
|
||||||
elements->erase(std::remove_if(elements->begin(), elements->end(), [el](xmlpp::Node *node){return !isAncestor(el, node);}));
|
|
||||||
|
|
||||||
return getCollection(ctx, elements);
|
for (auto node: elements)
|
||||||
|
{
|
||||||
|
if (isAncestor(el, node)) {
|
||||||
|
res->push_back(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getCollection(ctx, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue
|
static JSValue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user