mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +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
|
||||
#endif
|
||||
|
||||
#ifndef SEXP_MAX_VECTOR_LENGTH
|
||||
#define SEXP_MAX_VECTOR_LENGTH (SEXP_MAX_FIXNUM >> 1)
|
||||
#endif
|
||||
|
||||
#ifndef SEXP_DEFAULT_EQUAL_DEPTH
|
||||
#define SEXP_DEFAULT_EQUAL_DEPTH 10000
|
||||
#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 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 < 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),
|
||||
SEXP_VECTOR);
|
||||
if (sexp_exceptionp(vec)) return vec;
|
||||
|
|
Loading…
Add table
Reference in a new issue