diff --git a/external/njs_shell.c b/external/njs_shell.c index 1228b3746..aeab226c2 100644 --- a/external/njs_shell.c +++ b/external/njs_shell.c @@ -2950,7 +2950,6 @@ njs_qjs_object_completions(njs_engine_t *engine, JSContext *ctx, for (n = 0; n < length; n++) { key.start = (u_char *) JS_AtomToCString(ctx, ptab[n].atom); - JS_FreeAtom(ctx, ptab[n].atom); if (njs_slow_path(key.start == NULL)) { goto fail; } @@ -2993,7 +2992,7 @@ njs_qjs_object_completions(njs_engine_t *engine, JSContext *ctx, JS_FreeCString(ctx, (const char *) key.start); } - js_free_rt(JS_GetRuntime(ctx), ptab); + qjs_free_prop_enum(ctx, ptab, length); prototype = JS_GetPrototype(ctx, object); if (JS_IsException(prototype)) { @@ -3017,7 +3016,7 @@ njs_qjs_object_completions(njs_engine_t *engine, JSContext *ctx, } if (ptab != NULL) { - js_free_rt(JS_GetRuntime(ctx), ptab); + qjs_free_prop_enum(ctx, ptab, length); } JS_FreeValue(ctx, object); diff --git a/external/qjs_query_string_module.c b/external/qjs_query_string_module.c index 3059ee1be..423222342 100644 --- a/external/qjs_query_string_module.c +++ b/external/qjs_query_string_module.c @@ -727,19 +727,6 @@ qjs_query_string_push_array(JSContext *cx, njs_chb_t *chain, JSValue key, } -static void -qjs_free_prop_enum(JSContext *cx, JSPropertyEnum *tab, uint32_t len) -{ - uint32_t i; - - for (i = 0; i < len; i++) { - JS_FreeAtom(cx, tab[i].atom); - } - - js_free(cx, tab); -} - - static JSValue qjs_query_string_stringify_internal(JSContext *cx, JSValue obj, njs_str_t *sep, njs_str_t *eq, JSValue encoder) diff --git a/src/qjs.c b/src/qjs.c index 15a575a28..52401983a 100644 --- a/src/qjs.c +++ b/src/qjs.c @@ -1027,6 +1027,19 @@ qjs_string_create_chb(JSContext *cx, njs_chb_t *chain) } +void +qjs_free_prop_enum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len) +{ + uint32_t i; + + for(i = 0; i < len; i++) { + JS_FreeAtom(ctx, tab[i].atom); + } + + js_free(ctx, tab); +} + + JSValue qjs_string_hex(JSContext *cx, const njs_str_t *src) { diff --git a/src/qjs.h b/src/qjs.h index 54f96dfec..7c13f0392 100644 --- a/src/qjs.h +++ b/src/qjs.h @@ -127,6 +127,8 @@ JSValue qjs_typed_array_data(JSContext *ctx, JSValueConst value, JS_NewStringLen(ctx, (const char *) (data), len) JSValue qjs_string_create_chb(JSContext *cx, njs_chb_t *chain); +void qjs_free_prop_enum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len); + JSValue qjs_string_hex(JSContext *cx, const njs_str_t *src); JSValue qjs_string_base64(JSContext *cx, const njs_str_t *src); JSValue qjs_string_base64url(JSContext *cx, const njs_str_t *src);