Skip to content

Commit f6a2a79

Browse files
committed
QuickJS: fixed njs_qjs_object_completions().
This commit also exposed qjs_free_prop_enum() as public.
1 parent 6736121 commit f6a2a79

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

external/njs_shell.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -2950,7 +2950,6 @@ njs_qjs_object_completions(njs_engine_t *engine, JSContext *ctx,
29502950

29512951
for (n = 0; n < length; n++) {
29522952
key.start = (u_char *) JS_AtomToCString(ctx, ptab[n].atom);
2953-
JS_FreeAtom(ctx, ptab[n].atom);
29542953
if (njs_slow_path(key.start == NULL)) {
29552954
goto fail;
29562955
}
@@ -2993,7 +2992,7 @@ njs_qjs_object_completions(njs_engine_t *engine, JSContext *ctx,
29932992
JS_FreeCString(ctx, (const char *) key.start);
29942993
}
29952994

2996-
js_free_rt(JS_GetRuntime(ctx), ptab);
2995+
qjs_free_prop_enum(ctx, ptab, length);
29972996

29982997
prototype = JS_GetPrototype(ctx, object);
29992998
if (JS_IsException(prototype)) {
@@ -3017,7 +3016,7 @@ njs_qjs_object_completions(njs_engine_t *engine, JSContext *ctx,
30173016
}
30183017

30193018
if (ptab != NULL) {
3020-
js_free_rt(JS_GetRuntime(ctx), ptab);
3019+
qjs_free_prop_enum(ctx, ptab, length);
30213020
}
30223021

30233022
JS_FreeValue(ctx, object);

external/qjs_query_string_module.c

-13
Original file line numberDiff line numberDiff line change
@@ -727,19 +727,6 @@ qjs_query_string_push_array(JSContext *cx, njs_chb_t *chain, JSValue key,
727727
}
728728

729729

730-
static void
731-
qjs_free_prop_enum(JSContext *cx, JSPropertyEnum *tab, uint32_t len)
732-
{
733-
uint32_t i;
734-
735-
for (i = 0; i < len; i++) {
736-
JS_FreeAtom(cx, tab[i].atom);
737-
}
738-
739-
js_free(cx, tab);
740-
}
741-
742-
743730
static JSValue
744731
qjs_query_string_stringify_internal(JSContext *cx, JSValue obj, njs_str_t *sep,
745732
njs_str_t *eq, JSValue encoder)

src/qjs.c

+13
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,19 @@ qjs_string_create_chb(JSContext *cx, njs_chb_t *chain)
10271027
}
10281028

10291029

1030+
void
1031+
qjs_free_prop_enum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len)
1032+
{
1033+
uint32_t i;
1034+
1035+
for(i = 0; i < len; i++) {
1036+
JS_FreeAtom(ctx, tab[i].atom);
1037+
}
1038+
1039+
js_free(ctx, tab);
1040+
}
1041+
1042+
10301043
JSValue
10311044
qjs_string_hex(JSContext *cx, const njs_str_t *src)
10321045
{

src/qjs.h

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ JSValue qjs_typed_array_data(JSContext *ctx, JSValueConst value,
127127
JS_NewStringLen(ctx, (const char *) (data), len)
128128
JSValue qjs_string_create_chb(JSContext *cx, njs_chb_t *chain);
129129

130+
void qjs_free_prop_enum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len);
131+
130132
JSValue qjs_string_hex(JSContext *cx, const njs_str_t *src);
131133
JSValue qjs_string_base64(JSContext *cx, const njs_str_t *src);
132134
JSValue qjs_string_base64url(JSContext *cx, const njs_str_t *src);

0 commit comments

Comments
 (0)