diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-10-09 21:51:05 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-10-09 21:51:05 -0700 |
commit | 570a4cd9315f1a2189cb6d1877aa13a78ec00f0a (patch) | |
tree | 0e73977f4734902cd91ceb26ebb099feec0eb175 | |
parent | 6ce1525fee353cd85ce9e8a1f76be29fd390b5ae (diff) | |
download | txr-570a4cd9315f1a2189cb6d1877aa13a78ec00f0a.tar.gz txr-570a4cd9315f1a2189cb6d1877aa13a78ec00f0a.tar.bz2 txr-570a4cd9315f1a2189cb6d1877aa13a78ec00f0a.zip |
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.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | stream.c | 11 |
2 files changed, 16 insertions, 4 deletions
@@ -1,5 +1,14 @@ | |||
1 | 2014-10-09 Kaz Kylheku <kaz@kylheku.com> | 1 | 2014-10-09 Kaz Kylheku <kaz@kylheku.com> |
2 | 2 | ||
3 | Fix gc safety issue in abs_path_p function. | ||
4 | |||
5 | * stream.c (ap_regex): New static variable. | ||
6 | (abs_path_p): Remove local reg variable; replace | ||
7 | uses of reg with ap_regex. | ||
8 | (stream_init): gc-protect ap_regex. | ||
9 | |||
10 | 2014-10-09 Kaz Kylheku <kaz@kylheku.com> | ||
11 | |||
3 | * stream.c (stream_init): No need to gc-protect | 12 | * stream.c (stream_init): No need to gc-protect |
4 | std_input, std_output, std_debug, std_error and std_null. These are | 13 | std_input, std_output, std_debug, std_error and std_null. These are |
5 | not ordinary variables but macros which expand to locations in the | 14 | 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) | |||
2527 | } | 2527 | } |
2528 | } | 2528 | } |
2529 | 2529 | ||
2530 | static val ap_regex; | ||
2531 | |||
2530 | val abs_path_p(val path) | 2532 | val abs_path_p(val path) |
2531 | { | 2533 | { |
2532 | static val reg; | ||
2533 | val ch; | 2534 | val ch; |
2534 | 2535 | ||
2535 | if (length(path) == zero) | 2536 | if (length(path) == zero) |
@@ -2537,10 +2538,10 @@ val abs_path_p(val path) | |||
2537 | if ((ch = chr_str(path, zero)) == chr('/') || ch == chr('\\')) | 2538 | if ((ch = chr_str(path, zero)) == chr('/') || ch == chr('\\')) |
2538 | return t; | 2539 | return t; |
2539 | 2540 | ||
2540 | if (!reg) | 2541 | if (!ap_regex) |
2541 | reg = regex_compile(lit("[A-Za-z0-9]+:[/\\\\]"), nil); | 2542 | ap_regex = regex_compile(lit("[A-Za-z0-9]+:[/\\\\]"), nil); |
2542 | 2543 | ||
2543 | if (match_regex(path, reg, zero)) | 2544 | if (match_regex(path, ap_regex, zero)) |
2544 | return t; | 2545 | return t; |
2545 | 2546 | ||
2546 | return nil; | 2547 | return nil; |
@@ -2548,6 +2549,8 @@ val abs_path_p(val path) | |||
2548 | 2549 | ||
2549 | void stream_init(void) | 2550 | void stream_init(void) |
2550 | { | 2551 | { |
2552 | prot1(&ap_regex); | ||
2553 | |||
2551 | detect_format_string(); | 2554 | detect_format_string(); |
2552 | 2555 | ||
2553 | dev_k = intern(lit("dev"), keyword_package); | 2556 | dev_k = intern(lit("dev"), keyword_package); |