1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-28 01:35:32 +00:00

[quickjs] JS_FreeValue in forms

This commit is contained in:
Witold Filipczyk 2023-01-21 21:03:16 +01:00
parent 642b94f03f
commit ac4e417a3c
4 changed files with 14 additions and 13 deletions

View File

@ -499,25 +499,20 @@ js_document_get_property_forms(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
if (!document->forms_nodeset) {
document->forms_nodeset = new(std::nothrow) xmlpp::Node::NodeSet;
}
if (!document->forms_nodeset) {
return JS_NULL;
}
xmlpp::Document *docu = (xmlpp::Document *)document->dom;
xmlpp::Element* root = (xmlpp::Element *)docu->get_root_node();
xmlpp::ustring xpath = "//form";
xmlpp::Node::NodeSet *elements = static_cast<xmlpp::Node::NodeSet *>(document->forms_nodeset);
xmlpp::Node::NodeSet *elements = new(std::nothrow) xmlpp::Node::NodeSet;
*elements = root->find(xpath);
if (elements->size() == 0) {
return JS_NULL;
}
JSValue rr = getForms(ctx, elements);
JS_FreeValue(ctx, rr);
return getForms(ctx, elements);
RETURN_JS(rr);
}
static JSValue

View File

@ -196,6 +196,7 @@ js_form_set_items(JSContext *ctx, JSValueConst this_val, void *node)
JS_SetPropertyStr(ctx, this_val, fc->name, JS_DupValue(ctx, obj));
}
}
JS_FreeValue(ctx, obj);
counter++;
}
}
@ -239,6 +240,7 @@ js_form_set_items2(JSContext *ctx, JSValueConst this_val, void *node)
JS_SetPropertyStr(ctx, this_val, fc->name, JS_DupValue(ctx, obj));
}
}
JS_FreeValue(ctx, obj);
counter++;
}
}

View File

@ -129,6 +129,7 @@ js_forms_set_items(JSContext *ctx, JSValueConst this_val, void *node)
JS_SetPropertyStr(ctx, this_val, form->name, JS_DupValue(ctx, v));
}
}
JS_FreeValue(ctx, v);
counter++;
}
}

View File

@ -1533,11 +1533,14 @@ quickjs_moved_form_state(struct form_state *fs)
static
void js_input_finalizer(JSRuntime *rt, JSValue val)
{
REF_JS(val);
struct form_state *fs = (struct form_state *)JS_GetOpaque(val, js_input_class_id);
JS_SetOpaque(val, nullptr);
fs->ecmascript_obj = JS_NULL;
map_inputs.erase(fs);
if (fs) {
fs->ecmascript_obj = JS_NULL;
map_inputs.erase(fs);
}
}