Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed njs_qjs_object_completions(). #866

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions external/njs_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down
13 changes: 0 additions & 13 deletions external/qjs_query_string_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions src/qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions src/qjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down