adding len limit on ffi auto-expand vars (issue #553)

This commit is contained in:
Alex Shinn 2019-08-15 23:42:17 +08:00
parent 39f34ffffb
commit 83cfc7dd53

View file

@ -48,6 +48,8 @@
(define *c++?* #f)
(define wdir ".")
(define auto-expand-limit (* 10 1024 1024))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; type objects
@ -1478,6 +1480,10 @@
(lambda ()
(let ((len (get-array-length func 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)
(cat " if (len" i " != " len ")\n"
" free(tmp" i ");\n"))
@ -1491,7 +1497,8 @@
"")
")"))
" calloc(len" i ", sizeof(tmp" i "[0]));\n"
" goto loop;\n")))))
" goto loop;\n"
"}\n")))))
(error-return?
;; TODO: free other results
" res = SEXP_FALSE;\n")