Skip to content

Commit 116bb86

Browse files
committed
FIX: DELINE / ENLINE does not check series' protection
fixes: metaeducation/rebol-issues#2325
1 parent dc27950 commit 116bb86

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/core/n-strings.c

+4
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ static struct digest {
573573
REBINT len = VAL_LEN(val);
574574
REBINT n;
575575

576+
if (IS_PROTECT_SERIES(VAL_SERIES(val))) Trap0(RE_PROTECTED);
577+
576578
if (D_REF(2)) { //lines
577579
Set_Block(D_RET, Split_Lines(val));
578580
return R_RET;
@@ -603,6 +605,8 @@ static struct digest {
603605
REBVAL *val = D_ARG(1);
604606
REBSER *ser = VAL_SERIES(val);
605607

608+
if (IS_PROTECT_SERIES(VAL_SERIES(val))) Trap0(RE_PROTECTED);
609+
606610
if (SERIES_TAIL(ser)) {
607611
if (VAL_BYTE_SIZE(val))
608612
Enline_Bytes(ser, VAL_INDEX(val), VAL_LEN(val));

src/tests/units/protect-test.r3

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ Rebol [
3939
--test-- "swap string" --assert is-protected-error? [swap str "0bad"]
4040
--test-- "swap binary" --assert is-protected-error? [swap bin #{0bad}]
4141

42+
;@@ https://github.com/rebol/rebol-issues/issues/2325
43+
str: protect "a^M^/b"
44+
--test-- "deline string" --assert is-protected-error? [deline str]
45+
--test-- "enline string" --assert is-protected-error? [enline str]
46+
47+
4248
===end-group===
4349

4450
~~~end-file~~~

0 commit comments

Comments
 (0)