bytes-converter: avoid unnecessary custodian registration

Some built-in bytes-converter combinations that were not
supposed to require custodian registration were neveretheless
registered, which created a small leak for some programs.
This commit is contained in:
Matthew Flatt 2018-03-10 06:56:06 -07:00
parent 3f2fd06cb0
commit f3596d96c2
2 changed files with 28 additions and 1 deletions

View File

@ -1662,5 +1662,32 @@
(test "\u039A\u03b1\u03BF\u03C3\u03C2" string-titlecase "\u039A\u0391\u039F\u03A3\u03A3") (test "\u039A\u03b1\u03BF\u03C3\u03C2" string-titlecase "\u039A\u0391\u039F\u03A3\u03A3")
(test "\u039A\u03b1\u03BF\u03C2 X" string-titlecase "\u039A\u0391\u039F\u03A3 x") (test "\u039A\u03b1\u03BF\u03C2 X" string-titlecase "\u039A\u0391\u039F\u03A3 x")
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Bytes converters and custodians - check that built-in conversions are
;; not registered
(let ([c (make-custodian)])
(parameterize ([current-custodian c])
(define converters
(append
(list
(bytes-open-converter "UTF-8" "UTF-8")
(bytes-open-converter "UTF-8-permissive" "UTF-8"))
(if (eq? 'unix (system-type))
null
(list
(bytes-open-converter "" "UTF-8")
(bytes-open-converter "UTF-8" "")))
(list
(bytes-open-converter "platform-UTF-8" "platform-UTF-16")
(bytes-open-converter "platform-UTF-8-permissive" "platform-UTF-16")
(bytes-open-converter "platform-UTF-16" "platform-UTF-8") )))
(custodian-shutdown-all c)
;; Make sure the convertes all still work --- not shut down by
;; the custodian
(for ([cvt (in-list converters)])
(bytes-convert cvt #"hello"))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs) (report-errs)

View File

@ -4206,7 +4206,7 @@ Scheme_Object *scheme_open_converter(const char *from_e, const char *to_e)
else else
permissive = 0; permissive = 0;
cd = NULL; cd = NULL;
need_regis = (*to_e && *from_e); need_regis = 0;
} else if ((!strcmp(from_e, "platform-UTF-8") } else if ((!strcmp(from_e, "platform-UTF-8")
|| !strcmp(from_e, "platform-UTF-8-permissive")) || !strcmp(from_e, "platform-UTF-8-permissive"))
&& !strcmp(to_e, "platform-UTF-16")) { && !strcmp(to_e, "platform-UTF-16")) {