Skip to content

Commit

Permalink
WIP: issue tbeu#241: range checking
Browse files Browse the repository at this point in the history
  • Loading branch information
seanm committed Mar 4, 2024
1 parent 492ea83 commit ac8bce4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/read_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@
readcount += j; \
if ( j == block_size ) { \
for ( j = 0; j < block_size; j++ ) { \
data[i + j] = (T)SwapFunc(&v[j]); \
auto xxx = SwapFunc(&v[j]); \
if (xxx >= data_min && xxx <= data_max) { \
data[i + j] = (T)xxx; \
} \
} \
} else { \
err_ = 1; \
Expand Down Expand Up @@ -272,6 +275,8 @@
#undef READ_TYPED_FUNC2

#define READ_TYPE mat_uint16_t
#define READ_TYPE_MIN 0
#define READ_TYPE_MAX UINT16_MAX
#define READ_TYPE_TYPE READ_TYPE_UINT16
#define READ_TYPED_FUNC1 ReadUInt16Data
#define READ_TYPED_FUNC2 ReadCompressedUInt16Data
Expand Down
2 changes: 1 addition & 1 deletion src/read_data_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#endif /* HAVE_MAT_UINT64_T */

static size_t
READ_TYPE_DOUBLE_DATA(mat_t *mat, READ_TYPE *data, size_t len)
READ_TYPE_DOUBLE_DATA(mat_t *mat, READ_TYPE *data, READ_TYPE data_min, READ_TYPE data_max, size_t len)
{
size_t readcount;
#if READ_TYPE_TYPE == READ_TYPE_DOUBLE
Expand Down

0 comments on commit ac8bce4

Please sign in to comment.