mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
adding len limit on ffi auto-expand vars (issue #553)
This commit is contained in:
parent
39f34ffffb
commit
83cfc7dd53
1 changed files with 8 additions and 1 deletions
|
@ -48,6 +48,8 @@
|
||||||
(define *c++?* #f)
|
(define *c++?* #f)
|
||||||
(define wdir ".")
|
(define wdir ".")
|
||||||
|
|
||||||
|
(define auto-expand-limit (* 10 1024 1024))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; type objects
|
;; type objects
|
||||||
|
|
||||||
|
@ -1478,6 +1480,10 @@
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let ((len (get-array-length func a))
|
(let ((len (get-array-length func a))
|
||||||
(i (type-index a)))
|
(i (type-index a)))
|
||||||
|
(cat " if (len" i " > " auto-expand-limit ") {\n"
|
||||||
|
" res = sexp_user_exception(ctx, self, "
|
||||||
|
"\"exceeded max auto-expand len in " (func-scheme-name func) "\", SEXP_NULL);\n"
|
||||||
|
"} else {\n")
|
||||||
(if (number? len)
|
(if (number? len)
|
||||||
(cat " if (len" i " != " len ")\n"
|
(cat " if (len" i " != " len ")\n"
|
||||||
" free(tmp" i ");\n"))
|
" free(tmp" i ");\n"))
|
||||||
|
@ -1491,7 +1497,8 @@
|
||||||
"")
|
"")
|
||||||
")"))
|
")"))
|
||||||
" calloc(len" i ", sizeof(tmp" i "[0]));\n"
|
" calloc(len" i ", sizeof(tmp" i "[0]));\n"
|
||||||
" goto loop;\n")))))
|
" goto loop;\n"
|
||||||
|
"}\n")))))
|
||||||
(error-return?
|
(error-return?
|
||||||
;; TODO: free other results
|
;; TODO: free other results
|
||||||
" res = SEXP_FALSE;\n")
|
" res = SEXP_FALSE;\n")
|
||||||
|
|
Loading…
Add table
Reference in a new issue