Skip to content

Commit 1d215f5

Browse files
committed
FIX: CRASH when removing 32768 or more bytes from the head of series
1 parent 47a0f5d commit 1d215f5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/include/sys-value.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static REBCNT bit_sizes[4] = { 8, 16, 32, 64 };
448448
#define VAL_STR_IS_ASCII(v) (VAL_BYTE_SIZE(v) && !Is_Not_ASCII(VAL_BIN_DATA(v), VAL_LEN(v)))
449449

450450
// Bias is empty space in front of head:
451-
#define SERIES_BIAS(s) (REBCNT)(SERIES_FLAGS(s) >> 16)
451+
#define SERIES_BIAS(s) (REBCNT)((SERIES_FLAGS(s) >> 16) & 0xffff)
452452
#define MAX_SERIES_BIAS 0x1000
453453
#define SERIES_SET_BIAS(s,b) (SERIES_FLAGS(s) = (SERIES_FLAGS(s) & 0xffff) | (b << 16))
454454
#define SERIES_ADD_BIAS(s,b) (SERIES_FLAGS(s) += (b << 16))

src/tests/units/series-test.r3

+5
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ Rebol [
238238
--assert 1 = length? b
239239
--assert 10 = first b
240240

241+
--test-- "issue-2397"
242+
;@@ https://github.com/rebol/rebol-issues/issues/2397
243+
b: make binary! 40000 insert/dup b 0 40000
244+
remove/part b to integer! #{8000}
245+
241246
===end-group===
242247

243248
===start-group=== "SORT"

0 commit comments

Comments
 (0)