Skip to content

Commit

Permalink
error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPxt committed Sep 6, 2024
1 parent db314b1 commit 917fa5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/src/buffering_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ void buffering_json_init(uint8_t *flash_buffer, uint16_t flash_buffer_size) {
void buffering_json_reset() { flash_json.pos = 0; }

int buffering_json_append(uint8_t *data, int length) {
if (data == NULL || flash_json.data == NULL) {
return 0;
}

// Flash in use, append to flash
if (flash_json.size - flash_json.pos >= length) {
MEMCPY_NV(flash_json.data + flash_json.pos, data, (size_t)length);
Expand Down
6 changes: 3 additions & 3 deletions app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ parser_error_t parser_createJsonTemplate(parser_context_t *ctx) {
uint16_t address_len = 0;
chunk_t chunks[MAX_FIELDS_IN_INPUT_DATA] = {0};

parser_readSingleByte(ctx, &tx_type);
CHECK_ERROR(parser_readSingleByte(ctx, &tx_type));

for (int i = 0; i < MAX_FIELDS_IN_INPUT_DATA; i++) {
parser_readSingleByte(ctx, &chunks[i].len);
CHECK_ERROR(parser_readSingleByte(ctx, &chunks[i].len));
if (chunks[i].len > 0) {
parser_readBytes(ctx, (uint8_t **)&chunks[i].data, chunks[i].len);
CHECK_ERROR(parser_readBytes(ctx, (uint8_t **)&chunks[i].data, chunks[i].len));
} else {
chunks[i].data = (char *)"";
}
Expand Down

0 comments on commit 917fa5e

Please sign in to comment.