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

Throw exception on out of memory in dynamic buffer #838

Merged
merged 1 commit into from
Jan 20, 2025
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
13 changes: 6 additions & 7 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1539,12 +1539,6 @@ void *js_realloc_rt(JSRuntime *rt, void *ptr, size_t size)
return ptr;
}

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 @@ -1687,9 +1681,14 @@ static inline int js_resize_array(JSContext *ctx, void **parray, int elem_size,
return 0;
}

static void *js_dbuf_realloc(void *ctx, void *ptr, size_t size)
{
return js_realloc(ctx, ptr, size);
}

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

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