Skip to content

Commit

Permalink
Add js_dbuf_realloc to avoid ubsan error
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Jul 1, 2024
1 parent b9de2b0 commit 07fa1cb
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit 07fa1cb

Please sign in to comment.