1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

[quickjs] document fixes

This commit is contained in:
Witold Filipczyk 2022-01-30 13:49:57 +01:00
parent 10d2fb6c2b
commit 2dd9a0c00e

View File

@ -222,7 +222,6 @@ js_document_set_property_cookie(JSContext *ctx, JSValueConst this_val, JSValue v
#endif #endif
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx); struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
struct view_state *vs; struct view_state *vs;
struct string *cookies;
vs = interpreter->vs; vs = interpreter->vs;
if (!vs) { if (!vs) {
@ -232,13 +231,18 @@ js_document_set_property_cookie(JSContext *ctx, JSValueConst this_val, JSValue v
return JS_NULL; return JS_NULL;
} }
const char *text; const char *text;
char *str;
size_t len; size_t len;
text = JS_ToCStringLen(ctx, &len, val); text = JS_ToCStringLen(ctx, &len, val);
if (!text) { if (!text) {
return JS_EXCEPTION; return JS_EXCEPTION;
} }
set_cookie(vs->uri, text); str = stracpy(text);
if (str) {
set_cookie(vs->uri, str);
mem_free(str);
}
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -808,7 +812,8 @@ js_document_set_property_title(JSContext *ctx, JSValueConst this_val, JSValue va
doc_view = vs->doc_view; doc_view = vs->doc_view;
document = doc_view->document; document = doc_view->document;
const char *str, *string; const char *str;
char *string;
size_t len; size_t len;
str = JS_ToCStringLen(ctx, &len, val); str = JS_ToCStringLen(ctx, &len, val);