Add js_dbuf_realloc to avoid ubsan error

This commit is contained in:
Andrew Johnson 2024-07-02 01:43:34 +03:00 committed by GitHub
parent b9de2b0bf8
commit 07fa1cbc4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
@ -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) {