mirror of
https://github.com/bellard/quickjs.git
synced 2025-09-27 05:38:45 +03:00
fixed realloc(0) may alloc min unit memory on some allocator
This commit is contained in:
parent
a8b2d7c2b2
commit
68acb60984
@ -2448,7 +2448,7 @@ int lre_exec(uint8_t **capture,
|
|||||||
stack_buf = alloca(alloca_size);
|
stack_buf = alloca(alloca_size);
|
||||||
ret = lre_exec_backtrack(s, capture, stack_buf, 0, bc_buf + RE_HEADER_LEN,
|
ret = lre_exec_backtrack(s, capture, stack_buf, 0, bc_buf + RE_HEADER_LEN,
|
||||||
cbuf + (cindex << cbuf_type), FALSE);
|
cbuf + (cindex << cbuf_type), FALSE);
|
||||||
lre_realloc(s->opaque, s->state_stack, 0);
|
lre_free(s->opaque, s->state_stack);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,5 +56,6 @@ int lre_check_stack_overflow(void *opaque, size_t alloca_size);
|
|||||||
/* must be provided by the user, return non zero if time out */
|
/* must be provided by the user, return non zero if time out */
|
||||||
int lre_check_timeout(void *opaque);
|
int lre_check_timeout(void *opaque);
|
||||||
void *lre_realloc(void *opaque, void *ptr, size_t size);
|
void *lre_realloc(void *opaque, void *ptr, size_t size);
|
||||||
|
void lre_free(void *opaque, void *ptr);
|
||||||
|
|
||||||
#endif /* LIBREGEXP_H */
|
#endif /* LIBREGEXP_H */
|
||||||
|
@ -44594,6 +44594,13 @@ void *lre_realloc(void *opaque, void *ptr, size_t size)
|
|||||||
return js_realloc_rt(ctx->rt, ptr, size);
|
return js_realloc_rt(ctx->rt, ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lre_free(void *opaque, void *ptr)
|
||||||
|
{
|
||||||
|
JSContext *ctx = opaque;
|
||||||
|
/* No JS exception is raised here */
|
||||||
|
js_free_rt(ctx->rt, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
static JSValue js_regexp_escape(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_regexp_escape(JSContext *ctx, JSValueConst this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValueConst *argv)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user