Skip to content

Add js_realloc_opaque to avoid ubsan error #455

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

Merged
merged 3 commits into from
Jul 1, 2024
Merged
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
8 changes: 7 additions & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,12 @@ void *js_realloc_rt(JSRuntime *rt, void *ptr, size_t size)
return rt->mf.js_realloc(&rt->malloc_state, ptr, size);
}

static void *js_dbuf_realloc(void *opaque, void *ptr, size_t size)
{
JSRuntime *rt = opaque;
return js_realloc_rt(rt, ptr, size);
}

size_t js_malloc_usable_size_rt(JSRuntime *rt, const void *ptr)
{
return rt->mf.js_malloc_usable_size(ptr);
Expand Down Expand Up @@ -1517,7 +1523,7 @@ static inline int js_resize_array(JSContext *ctx, void **parray, int elem_size,

static inline void js_dbuf_init(JSContext *ctx, DynBuf *s)
{
dbuf_init2(s, ctx->rt, (DynBufReallocFunc *)js_realloc_rt);
dbuf_init2(s, ctx->rt, js_dbuf_realloc);
}

static inline int is_digit(int c) {
Expand Down
Loading