Skip to content

Commit

Permalink
Differentiate OBJECT! and ARRAY access in protect
Browse files Browse the repository at this point in the history
In R3-Alpha, it was sometimes the case that the "frame" series of an
object was accessed via VAL_SERIES instead of what was then VAL_FRAME
(now VAL_CONTEXT_VARLIST).  Most of these have been vetted from the
system to go through the accessor appropriate for the type, but this
case in PROTECT had not been changed.

Caught by a runtime check in the debug build.
  • Loading branch information
hostilefork committed Jan 12, 2016
1 parent c373e89 commit dd39dda
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/core/f-blocks.c
Expand Up @@ -357,18 +357,26 @@ REBCNT Find_Same_Array(REBARR *search_values, const REBVAL *value)
//
void Unmark(REBVAL *val)
{
REBSER *series;
if (ANY_SERIES(val))
series = VAL_SERIES(val);
REBARR *array;

if (ANY_ARRAY(val))
array = VAL_ARRAY(val);
else if (ANY_CONTEXT(val))
series = ARRAY_SERIES(CONTEXT_VARLIST(VAL_CONTEXT(val)));
else
array = CONTEXT_VARLIST(VAL_CONTEXT(val));
else {
// Shouldn't have marked recursively any non-array series (no need)
//
assert(
!ANY_SERIES(val)
|| !SERIES_GET_FLAG(VAL_SERIES(val), OPT_SER_MARK)
);
return;
}

if (!SERIES_GET_FLAG(series, OPT_SER_MARK)) return; // avoid loop
if (!ARRAY_GET_FLAG(array, OPT_SER_MARK)) return; // avoid loop

SERIES_CLR_FLAG(series, OPT_SER_MARK);
ARRAY_CLR_FLAG(array, OPT_SER_MARK);

for (val = VAL_ARRAY_HEAD(val); NOT_END(val); val++)
for (val = ARRAY_HEAD(array); NOT_END(val); val++)
Unmark(val);
}

0 comments on commit dd39dda

Please sign in to comment.