Skip to content

Commit d2b8cd5

Browse files
earlOldes
authored andcommitted
FIX: Ensure proper path component types during refinement processing
A self-declared refinement processing "hack" fails, in certain situations, to re-verify that path components accessed in refinement processing are words before using word-specific accessor functions on them. Without this fix (example as reported by Sunanda in CC#1977): >> a: func [/b] [1] >> a/b/% ;; R3 crashes at this point. With this fix: >> a/b/% ** Script error: incompatible refinement: %"" This patch is a slight variation of an earlier fix written by Shixin Zeng (zsx/r3@72b5d98). Fixes: Oldes/Rebol-issues#1977 (cherry picked from commit c3d6e02)
1 parent ef6931f commit d2b8cd5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/core/c-do.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,10 @@ x*/ static REBINT Do_Args_Light(REBVAL *func, REBVAL *path, REBSER *block, REBCN
746746
}
747747

748748
// Hack to process remaining path:
749-
if (path && NOT_END(path)) goto more_path;
750-
// Trap2(RE_NO_REFINE, Func_Word(dsf), path);
749+
if (path && NOT_END(path)) {
750+
if (!IS_WORD(path)) Trap1(RE_BAD_REFINE, path);
751+
goto more_path;
752+
}
751753

752754
return index;
753755
}

src/tests/units/crash-test.r3

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ Rebol [
2323
recycle ;@@ <-- it was crashing here
2424
--assert 1 = a
2525

26+
--test-- "issue-1977"
27+
;@@ https://github.com/Oldes/Rebol-issues/issues/1977
28+
a: func [/b] [1]
29+
--assert error? try [a/b/%] ;- no crash, just error!
30+
2631
===end-group===
2732

2833
~~~end-file~~~

0 commit comments

Comments
 (0)