From 2237cb002d49cc793f9b3b752be5fdb290c4d102 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Fri, 14 Jan 2022 19:48:40 +0100 Subject: [PATCH] [quickjs] Added location_goto_const to avoid some warnings --- src/ecmascript/ecmascript.c | 11 +++++++++++ src/ecmascript/ecmascript.h | 1 + src/ecmascript/quickjs/document.c | 4 ++-- src/ecmascript/quickjs/location.c | 18 +++++++++--------- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/ecmascript/ecmascript.c b/src/ecmascript/ecmascript.c index 055f26c1..88303787 100644 --- a/src/ecmascript/ecmascript.c +++ b/src/ecmascript/ecmascript.c @@ -740,6 +740,17 @@ delayed_goto(void *data) mem_free(deg); } +void +location_goto_const(struct document_view *doc_view, const char *url) +{ + char *url2 = stracpy(url); + + if (url2) { + location_goto(doc_view, url2); + mem_free(url2); + } +} + void location_goto(struct document_view *doc_view, char *url) { diff --git a/src/ecmascript/ecmascript.h b/src/ecmascript/ecmascript.h index bc58cffb..3f6183bb 100644 --- a/src/ecmascript/ecmascript.h +++ b/src/ecmascript/ecmascript.h @@ -154,6 +154,7 @@ void toggle_ecmascript(struct session *ses); void *document_parse(struct document *document); void free_document(void *doc); void location_goto(struct document_view *doc_view, char *url); +void location_goto_const(struct document_view *doc_view, const char *url); extern char *console_error_filename; extern char *console_log_filename; diff --git a/src/ecmascript/quickjs/document.c b/src/ecmascript/quickjs/document.c index 881bdd0e..fa49b27f 100644 --- a/src/ecmascript/quickjs/document.c +++ b/src/ecmascript/quickjs/document.c @@ -655,7 +655,7 @@ js_document_set_property_location(JSContext *ctx, JSValueConst this_val, JSValue return JS_EXCEPTION; } - location_goto(doc_view, url); + location_goto_const(doc_view, url); JS_FreeCString(ctx, url); return JS_UNDEFINED; @@ -885,7 +885,7 @@ js_document_set_property_url(JSContext *ctx, JSValueConst this_val, JSValue val) if (!url) { return JS_EXCEPTION; } - location_goto(doc_view, url); + location_goto_const(doc_view, url); JS_FreeCString(ctx, url); return JS_UNDEFINED; diff --git a/src/ecmascript/quickjs/location.c b/src/ecmascript/quickjs/location.c index 3dc48aac..2cce20d7 100644 --- a/src/ecmascript/quickjs/location.c +++ b/src/ecmascript/quickjs/location.c @@ -355,7 +355,7 @@ js_location_set_property_hash(JSContext *ctx, JSValueConst this_val, JSValue val if (!str) { return JS_EXCEPTION; } - location_goto(vs->doc_view, str); + location_goto_const(vs->doc_view, str); JS_FreeCString(ctx, str); return JS_UNDEFINED; @@ -383,7 +383,7 @@ js_location_set_property_host(JSContext *ctx, JSValueConst this_val, JSValue val if (!str) { return JS_EXCEPTION; } - location_goto(vs->doc_view, str); + location_goto_const(vs->doc_view, str); JS_FreeCString(ctx, str); return JS_UNDEFINED; @@ -411,7 +411,7 @@ js_location_set_property_hostname(JSContext *ctx, JSValueConst this_val, JSValue if (!str) { return JS_EXCEPTION; } - location_goto(vs->doc_view, str); + location_goto_const(vs->doc_view, str); JS_FreeCString(ctx, str); return JS_UNDEFINED; @@ -439,7 +439,7 @@ js_location_set_property_href(JSContext *ctx, JSValueConst this_val, JSValue val if (!str) { return JS_EXCEPTION; } - location_goto(vs->doc_view, str); + location_goto_const(vs->doc_view, str); JS_FreeCString(ctx, str); return JS_UNDEFINED; @@ -467,7 +467,7 @@ js_location_set_property_pathname(JSContext *ctx, JSValueConst this_val, JSValue if (!str) { return JS_EXCEPTION; } - location_goto(vs->doc_view, str); + location_goto_const(vs->doc_view, str); JS_FreeCString(ctx, str); return JS_UNDEFINED; @@ -495,7 +495,7 @@ js_location_set_property_port(JSContext *ctx, JSValueConst this_val, JSValue val if (!str) { return JS_EXCEPTION; } - location_goto(vs->doc_view, str); + location_goto_const(vs->doc_view, str); JS_FreeCString(ctx, str); return JS_UNDEFINED; @@ -523,7 +523,7 @@ js_location_set_property_protocol(JSContext *ctx, JSValueConst this_val, JSValue if (!str) { return JS_EXCEPTION; } - location_goto(vs->doc_view, str); + location_goto_const(vs->doc_view, str); JS_FreeCString(ctx, str); return JS_UNDEFINED; @@ -551,7 +551,7 @@ js_location_set_property_search(JSContext *ctx, JSValueConst this_val, JSValue v if (!str) { return JS_EXCEPTION; } - location_goto(vs->doc_view, str); + location_goto_const(vs->doc_view, str); JS_FreeCString(ctx, str); return JS_UNDEFINED; @@ -572,7 +572,7 @@ js_location_reload(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst #endif return JS_EXCEPTION; } - location_goto(vs->doc_view, ""); + location_goto_const(vs->doc_view, ""); return JS_UNDEFINED; }