1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[quickjs] Check for NULL and return JS_EXCEPTION in contains

This commit is contained in:
Witold Filipczyk 2024-09-17 15:36:45 +02:00
parent d39a72afc8
commit 118a2438df
3 changed files with 20 additions and 9 deletions

View File

@ -2897,14 +2897,18 @@ js_element_contains(JSContext *ctx, JSValueConst this_val, int argc, JSValueCons
dom_node *el = (dom_node *)(js_getopaque(this_val, js_element_class_id));
if (!el) {
return JS_FALSE;
return JS_EXCEPTION;
}
//dom_node_ref(el);
dom_node *el2 = (dom_node *)(js_getopaque(argv[0], js_element_class_id));
dom_node *el2 = NULL;
if (!JS_IsNull(argv[0])) {
el2 = (dom_node *)(js_getopaque(argv[0], js_element_class_id));
}
if (!el2) {
//dom_node_unref(el);
return JS_FALSE;
return JS_EXCEPTION;
}
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);

View File

@ -1135,14 +1135,18 @@ js_fragment_contains(JSContext *ctx, JSValueConst this_val, int argc, JSValueCon
dom_node *el = (dom_node *)(js_getopaque_fragment(this_val, js_fragment_class_id));
if (!el) {
return JS_FALSE;
return JS_EXCEPTION;
}
dom_node *el2 = NULL;
if (!JS_IsNull(argv[0])) {
//dom_node_ref(el);
dom_node *el2 = (dom_node *)(js_getopaque_fragment(argv[0], js_fragment_class_id));
el2 = (dom_node *)(js_getopaque_fragment(argv[0], js_fragment_class_id));
}
if (!el2) {
//dom_node_unref(el);
return JS_FALSE;
return JS_EXCEPTION;
}
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);

View File

@ -1169,14 +1169,17 @@ js_text_contains(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *
dom_node *el = (dom_node *)(js_getopaque_text(this_val, js_text_class_id));
if (!el) {
return JS_FALSE;
return JS_EXCEPTION;
}
dom_node *el2 = NULL;
//dom_node_ref(el);
dom_node *el2 = (dom_node *)(js_getopaque_text(argv[0], js_text_class_id));
if (!JS_IsNull(argv[0])) {
el2 = (dom_node *)(js_getopaque_text(argv[0], js_text_class_id));
}
if (!el2) {
//dom_node_unref(el);
return JS_FALSE;
return JS_EXCEPTION;
}
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);