From 917fa5e162bb0f5c3b64818f2eb3cd3cf050dabc Mon Sep 17 00:00:00 2001 From: 0xPxt Date: Fri, 6 Sep 2024 10:34:57 +0200 Subject: [PATCH] error checking --- app/src/buffering_json.c | 4 ++++ app/src/parser_impl.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/buffering_json.c b/app/src/buffering_json.c index 1a0f2a4..1bc6ee3 100644 --- a/app/src/buffering_json.c +++ b/app/src/buffering_json.c @@ -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); diff --git a/app/src/parser_impl.c b/app/src/parser_impl.c index ae34ec5..68d9f51 100644 --- a/app/src/parser_impl.c +++ b/app/src/parser_impl.c @@ -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 *)""; }