1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

[quickjs] memleaks

This commit is contained in:
Witold Filipczyk 2024-07-19 21:01:27 +02:00
parent 83b3185e11
commit 95f45b7327
7 changed files with 22 additions and 20 deletions

View File

@ -79,11 +79,11 @@ document_parse_text(const char *charset, const char *data, size_t length)
dom_hubbub_parser *parser = NULL;
dom_hubbub_error error;
dom_hubbub_parser_params params;
dom_document *doc;
dom_document *doc = NULL;
params.enc = charset;
params.fix_enc = true;
params.enable_script = false;
params.enable_script = true;
params.msg = NULL;
params.script = NULL;
params.ctx = NULL;
@ -118,7 +118,6 @@ document_parse_text(const char *charset, const char *data, size_t length)
return doc;
}
void *
document_parse(struct document *document, struct string *source)
{
@ -136,7 +135,7 @@ free_document(void *doc)
if (!doc) {
return;
}
dom_node *ddd = (dom_node *)doc;
dom_html_document *ddd = (dom_html_document *)doc;
dom_node_unref(ddd);
}

View File

@ -483,7 +483,7 @@ void
debug_dump_xhtml(void *d)
{
#ifdef ECMASCRIPT_DEBUG
dom_document *doc = (dom_document *)d;
dom_html_document *doc = (dom_html_document *)d;
if (!doc) {
return;
@ -525,7 +525,7 @@ void
dump_xhtml(struct cache_entry *cached, struct document *document, int parse)
{
dom_exception exc; /* returned by libdom functions */
dom_document *doc = NULL; /* document, loaded into libdom */
dom_html_document *doc = NULL; /* document, loaded into libdom */
dom_node *root = NULL; /* root element of document */
void *mapa = NULL;
void *mapa_rev = NULL;
@ -652,7 +652,7 @@ void
walk2(struct document *document)
{
dom_exception exc; /* returned by libdom functions */
dom_document *doc = NULL; /* document, loaded into libdom */
dom_html_document *doc = NULL; /* document, loaded into libdom */
dom_node *root = NULL; /* root element of document */
if (!document->dom) {
@ -799,7 +799,7 @@ void
try_to_color(struct terminal *term, struct el_box *box, struct document *document, int vx, int vy)
{
dom_exception exc; /* returned by libdom functions */
dom_document *doc = NULL; /* document, loaded into libdom */
dom_html_document *doc = NULL; /* document, loaded into libdom */
dom_node *root = NULL; /* root element of document */
if (!document->dom) {

View File

@ -317,7 +317,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
struct cache_entry *cached = document->cached;
#ifdef CONFIG_ECMASCRIPT_SMJS
if (interpreter->document_obj) {
dom_document *doc = JS::GetMaybePtrFromReservedSlot<dom_document>((JSObject *)interpreter->document_obj, 0);
dom_html_document *doc = JS::GetMaybePtrFromReservedSlot<dom_html_document>((JSObject *)interpreter->document_obj, 0);
if (doc) {
document->dom = doc;
@ -326,7 +326,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
#endif
#ifdef CONFIG_QUICKJS
if (JS_IsObject(interpreter->document_obj)) {
dom_document *doc = js_doc_getopaque(interpreter->document_obj);
dom_html_document *doc = js_doc_getopaque(interpreter->document_obj);
if (doc) {
document->dom = doc;

View File

@ -21,7 +21,7 @@
void
el_insert_before(struct document *document, void *element, struct string *source)
{
dom_document *doc = (dom_document *)document->dom;
dom_html_document *doc = (dom_html_document *)document->dom;
dom_node *node = (dom_node *)element;
dom_string *text = NULL;
dom_exception exc = dom_string_create((const unsigned char *)source->source, source->length, &text);

View File

@ -59,6 +59,7 @@ void js_htmlColection_finalizer(JSRuntime *rt, JSValue val)
dom_html_collection *ns = (dom_html_collection *)(js_htmlCollection_GetOpaque(val));
if (ns) {
attr_erase_from_map_str(map_collections, ns);
dom_html_collection_unref(ns);
}
}

View File

@ -347,7 +347,7 @@ js_document_get_property_doctype(JSContext *ctx, JSValueConst this_val)
#endif
REF_JS(this_val);
dom_document *doc = (struct dom_document *)js_doc_getopaque(this_val);
dom_html_document *doc = (struct dom_html_document *)js_doc_getopaque(this_val);
if (!doc) {
return JS_NULL;
@ -1042,7 +1042,7 @@ js_document_addEventListener(JSContext *ctx, JSValueConst this_val, int argc, JS
if (!doc_private) {
return JS_NULL;
}
dom_document *doc = doc_private->node;
dom_html_document *doc = doc_private->node;
if (argc < 2) {
return JS_UNDEFINED;
@ -1126,7 +1126,7 @@ js_document_dispatchEvent(JSContext *ctx, JSValueConst this_val, int argc, JSVal
if (!doc_private) {
return JS_FALSE;
}
dom_document *doc = doc_private->node;
dom_html_document *doc = doc_private->node;
if (!doc) {
return JS_FALSE;
@ -1167,7 +1167,7 @@ js_document_removeEventListener(JSContext *ctx, JSValueConst this_val, int argc,
if (!doc_private) {
return JS_NULL;
}
dom_document *doc = (dom_document *)doc_private->node;
dom_html_document *doc = (dom_html_document *)doc_private->node;
dom_node_ref(doc);
if (argc < 2) {
@ -1282,7 +1282,7 @@ js_document_createDocumentFragment(JSContext *ctx, JSValueConst this_val, int ar
if (argc != 0) {
return JS_FALSE;
}
dom_document *doc = (struct dom_document *)js_doc_getopaque(this_val);
dom_html_document *doc = (struct dom_html_document *)js_doc_getopaque(this_val);
if (!doc) {
return JS_NULL;
@ -1312,7 +1312,7 @@ js_document_createElement(JSContext *ctx, JSValueConst this_val, int argc, JSVal
if (argc != 1) {
return JS_FALSE;
}
dom_document *doc = (struct dom_document *)js_doc_getopaque(this_val);
dom_html_document *doc = (struct dom_html_document *)js_doc_getopaque(this_val);
if (!doc) {
return JS_NULL;
@ -1361,7 +1361,7 @@ js_document_createTextNode(JSContext *ctx, JSValueConst this_val, int argc, JSVa
if (argc != 1) {
return JS_FALSE;
}
dom_document *doc = (struct dom_document *)js_doc_getopaque(this_val);
dom_html_document *doc = (struct dom_html_document *)js_doc_getopaque(this_val);
if (!doc) {
return JS_NULL;
@ -1538,7 +1538,7 @@ js_document_getElementsByTagName(JSContext *ctx, JSValueConst this_val, int argc
if (argc != 1) {
return JS_FALSE;
}
dom_document *doc = (struct dom_document *)js_doc_getopaque(this_val);
dom_html_document *doc = (struct dom_html_document *)js_doc_getopaque(this_val);
if (!doc) {
return JS_NULL;

View File

@ -3620,6 +3620,9 @@ void js_element_finalizer(JSRuntime *rt, JSValue val)
}
if (el) {
void *old_node_data = NULL;
dom_node_set_user_data(el, corestring_dom___ns_key_html_content_data, NULL, js_html_document_user_data_handler,
(void *) &old_node_data);
dom_node_unref(el);
}
@ -3717,7 +3720,6 @@ getElement(JSContext *ctx, void *node)
}
init_list(el_private->listeners);
el_private->node = node;
dom_node_ref((dom_node *)node);
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
el_private->interpreter = interpreter;