From 570a4cd9315f1a2189cb6d1877aa13a78ec00f0a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 9 Oct 2014 21:51:05 -0700 Subject: Fix gc safety issue in abs_path_p function. * stream.c (ap_regex): New static variable. (abs_path_p): Remove local reg variable; replace uses of reg with ap_regex. (stream_init): gc-protect ap_regex. --- ChangeLog | 9 +++++++++ stream.c | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8fa0faf5..19a8586d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-10-09 Kaz Kylheku + + Fix gc safety issue in abs_path_p function. + + * stream.c (ap_regex): New static variable. + (abs_path_p): Remove local reg variable; replace + uses of reg with ap_regex. + (stream_init): gc-protect ap_regex. + 2014-10-09 Kaz Kylheku * stream.c (stream_init): No need to gc-protect diff --git a/stream.c b/stream.c index 958ba9d5..48943fb4 100644 --- a/stream.c +++ b/stream.c @@ -2527,9 +2527,10 @@ static val open_files_star(val file_list, val substitute_stream) } } +static val ap_regex; + val abs_path_p(val path) { - static val reg; val ch; if (length(path) == zero) @@ -2537,10 +2538,10 @@ val abs_path_p(val path) if ((ch = chr_str(path, zero)) == chr('/') || ch == chr('\\')) return t; - if (!reg) - reg = regex_compile(lit("[A-Za-z0-9]+:[/\\\\]"), nil); + if (!ap_regex) + ap_regex = regex_compile(lit("[A-Za-z0-9]+:[/\\\\]"), nil); - if (match_regex(path, reg, zero)) + if (match_regex(path, ap_regex, zero)) return t; return nil; @@ -2548,6 +2549,8 @@ val abs_path_p(val path) void stream_init(void) { + prot1(&ap_regex); + detect_format_string(); dev_k = intern(lit("dev"), keyword_package); -- cgit v1.2.3