mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
apply an explicit max vector length check (issue #636)
This commit is contained in:
parent
b459e11ecf
commit
61f2983fad
2 changed files with 7 additions and 1 deletions
|
@ -787,6 +787,10 @@
|
||||||
#define SEXP_MAX_STACK_SIZE SEXP_INIT_STACK_SIZE*1000
|
#define SEXP_MAX_STACK_SIZE SEXP_INIT_STACK_SIZE*1000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SEXP_MAX_VECTOR_LENGTH
|
||||||
|
#define SEXP_MAX_VECTOR_LENGTH (SEXP_MAX_FIXNUM >> 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef SEXP_DEFAULT_EQUAL_DEPTH
|
#ifndef SEXP_DEFAULT_EQUAL_DEPTH
|
||||||
#define SEXP_DEFAULT_EQUAL_DEPTH 10000
|
#define SEXP_DEFAULT_EQUAL_DEPTH 10000
|
||||||
#endif
|
#endif
|
||||||
|
|
4
sexp.c
4
sexp.c
|
@ -1524,8 +1524,10 @@ sexp sexp_string_to_symbol_op (sexp ctx, sexp self, sexp_sint_t n, sexp str) {
|
||||||
|
|
||||||
sexp sexp_make_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp dflt) {
|
sexp sexp_make_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp dflt) {
|
||||||
sexp vec, *x;
|
sexp vec, *x;
|
||||||
int i, clen = sexp_unbox_fixnum(len);
|
sexp_sint_t i, clen = sexp_unbox_fixnum(len);
|
||||||
if (! clen) return sexp_global(ctx, SEXP_G_EMPTY_VECTOR);
|
if (! clen) return sexp_global(ctx, SEXP_G_EMPTY_VECTOR);
|
||||||
|
if (clen < 0 || clen > SEXP_MAX_VECTOR_LENGTH)
|
||||||
|
return sexp_xtype_exception(ctx, self, "vector length out of range", len);
|
||||||
vec = sexp_alloc_tagged(ctx, sexp_sizeof(vector) + clen*sizeof(sexp),
|
vec = sexp_alloc_tagged(ctx, sexp_sizeof(vector) + clen*sizeof(sexp),
|
||||||
SEXP_VECTOR);
|
SEXP_VECTOR);
|
||||||
if (sexp_exceptionp(vec)) return vec;
|
if (sexp_exceptionp(vec)) return vec;
|
||||||
|
|
Loading…
Add table
Reference in a new issue