Skip to content

Commit

Permalink
FIX: Invalid byte-size of protected vector! data
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Sep 30, 2021
1 parent d408975 commit c8198a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/include/sys-value.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,12 @@ enum {
};

static REBCNT bit_sizes[4] = { 8, 16, 32, 64 };
static REBCNT byte_sizes[4] = { 1, 2, 4, 8 };

#define VECT_TYPE(s) ((s)->size & 0xff)
#define VECT_BIT_SIZE(bits) (bit_sizes[bits & 3])
#define VECT_BYTE_SIZE(bits) (byte_sizes[bits & 3])
#define VAL_VEC_WIDTH(v) VECT_BYTE_SIZE(VECT_TYPE(VAL_SERIES(v)))



Expand Down Expand Up @@ -605,8 +608,6 @@ typedef struct Reb_Series_Ref
#define VAL_BIN_SKIP(v,n) BIN_SKIP(VAL_SERIES(v), (n))
#define VAL_BIN_TAIL(v) BIN_SKIP(VAL_SERIES(v), VAL_SERIES(v)->tail)

#define VAL_VEC_WIDTH(v) (VAL_SERIES(v)->info)

// Arg is a unicode value:
#define VAL_UNI(v) UNI_HEAD(VAL_SERIES(v))
#define VAL_UNI_HEAD(v) UNI_HEAD(VAL_SERIES(v))
Expand Down
5 changes: 5 additions & 0 deletions src/tests/units/vector-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ Rebol [
--assert [0 0] = to-block make vector! [integer! 32 2]
--assert [1 2] = to block! #[u16! [1 2]]

--test-- "to-binary vector!"
--assert #{01000200} = to binary! #[u16! [1 2]]
;@@ https://github.com/Oldes/Rebol-issues/issues/2458
--assert #{01000200} = to binary! protect #[u16! [1 2]]

--test-- "LOAD/MOLD on vector"
--assert v = load mold/all v
--assert v = do load mold v
Expand Down

0 comments on commit c8198a8

Please sign in to comment.