Skip to content

Commit 65e51c6

Browse files
Fix issue where a malformed enum_value payload would lead to a memory leak
1 parent 18792a3 commit 65e51c6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src_features/provide_enum_value/cmd_enum_value.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
#include "tlv.h"
99

1010
bool handle_tlv_payload(const uint8_t *payload, uint16_t size, bool to_free) {
11+
bool parsing_ret;
1112
s_enum_value_ctx ctx = {0};
1213

1314
cx_sha256_init(&ctx.struct_hash);
14-
if (!tlv_parse(payload, size, (f_tlv_data_handler) &handle_enum_value_struct, &ctx)) {
15-
return false;
16-
}
15+
parsing_ret = tlv_parse(payload, size, (f_tlv_data_handler) &handle_enum_value_struct, &ctx);
1716
if (to_free) mem_dealloc(sizeof(size));
17+
if (!parsing_ret) return false;
1818
if (!verify_enum_value_struct(&ctx)) {
1919
return false;
2020
}

0 commit comments

Comments
 (0)