summaryrefslogtreecommitdiffstats
authorKaz Kylheku <kaz@kylheku.com>2014-10-10 04:51:05 (GMT)
committer Kaz Kylheku <kaz@kylheku.com>2014-10-10 04:51:05 (GMT)
commit570a4cd9315f1a2189cb6d1877aa13a78ec00f0a (patch) (side-by-side diff)
tree0e73977f4734902cd91ceb26ebb099feec0eb175
parent6ce1525fee353cd85ce9e8a1f76be29fd390b5ae (diff)
downloadtxr-master.zip
txr-master.tar.gz
txr-master.tar.bz2
Fix gc safety issue in abs_path_p function.HEADmaster
* 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.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ChangeLog9
-rw-r--r--stream.c11
2 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fa0faf..19a8586 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/stream.c b/stream.c
index 958ba9d..48943fb 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);