Skip to content

Commit

Permalink
FIX: Overprotective PROTECT for path access to maps
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Feb 9, 2020
1 parent 9ab1b13 commit 70a3314
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/t-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@
REBVAL *val = 0;
REBINT n = 0;

if (pvs->setval) TRAP_PROTECT(VAL_SERIES(data));

if (IS_END(pvs->path+1)) val = pvs->setval;
if (IS_NONE(pvs->select)) return PE_NONE;

Expand All @@ -302,7 +304,6 @@

if (!n) return PE_NONE;

TRAP_PROTECT(VAL_SERIES(data));
pvs->value = VAL_BLK_SKIP(data, ((n-1)*2)+1);
return PE_OK;
}
Expand Down
9 changes: 9 additions & 0 deletions src/tests/units/map-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ Rebol [
--test-- "map-issue-598"
--assert error? try [make map! [[a] 1]]

;@@ https://github.com/rebol/rebol-issues/issues/1872
--test-- "map-issue-1872"
m: map [a: 42]
protect m
--assert error? err: try [m/a: 0]
--assert err/id = 'protected
--assert 42 = try [m/a]
unprotect m

===end-group===

===start-group=== "reflection"
Expand Down

0 comments on commit 70a3314

Please sign in to comment.