Skip to content

Commit

Permalink
Load: Assert permitted types for integer storage code
Browse files Browse the repository at this point in the history
  • Loading branch information
tlsa committed Aug 26, 2024
1 parent 789e7f8 commit 918c250
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ static inline cyaml_err_t cyaml__store_int(
int64_t max;
int64_t min;

assert(schema->type == CYAML_INT ||
schema->type == CYAML_ENUM);

if (schema->data_size == 0 || schema->data_size > sizeof(value)) {
return CYAML_ERR_INVALID_DATA_SIZE;
}
Expand Down Expand Up @@ -212,6 +215,10 @@ static inline cyaml_err_t cyaml__store_uint(
{
uint64_t max;

assert(schema->type == CYAML_UINT ||
schema->type == CYAML_FLAGS ||
schema->type == CYAML_BITFIELD);

if (schema->data_size == 0 || schema->data_size > sizeof(value)) {
return CYAML_ERR_INVALID_DATA_SIZE;
}
Expand Down

0 comments on commit 918c250

Please sign in to comment.