diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | stream.c | 11 |
2 files changed, 16 insertions, 4 deletions
@@ -1,5 +1,14 @@ 2014-10-09 Kaz Kylheku <kaz@kylheku.com> + 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 <kaz@kylheku.com> + * stream.c (stream_init): No need to gc-protect std_input, std_output, std_debug, std_error and std_null. These are not ordinary variables but macros which expand to locations in the @@ -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); |