Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 6d83549

Browse files
authored
Merge pull request #734 from HowJMay/mam_fix
fix(serializer): Ensure not derefering not-string field
2 parents 24f7021 + 6bba58f commit 6d83549

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

accelerator/core/serializer/ser_mam.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static status_t send_mam_message_mam_v1_req_deserialize(cJSON const* const json_
6060
}
6161

6262
json_value = cJSON_GetObjectItemCaseSensitive(json_key, "seed");
63-
if (json_value != NULL) {
63+
if (json_value && json_value->valuestring) {
6464
size_t seed_size = strnlen(json_value->valuestring, NUM_TRYTES_ADDRESS);
6565

6666
if (seed_size != NUM_TRYTES_HASH) {
@@ -73,7 +73,7 @@ static status_t send_mam_message_mam_v1_req_deserialize(cJSON const* const json_
7373
}
7474

7575
json_value = cJSON_GetObjectItemCaseSensitive(json_key, "chid");
76-
if (json_value != NULL) {
76+
if (json_value && json_value->valuestring) {
7777
size_t chid_size = strnlen(json_value->valuestring, NUM_TRYTES_ADDRESS);
7878

7979
if (chid_size != NUM_TRYTES_HASH) {
@@ -86,7 +86,7 @@ static status_t send_mam_message_mam_v1_req_deserialize(cJSON const* const json_
8686
}
8787

8888
json_value = cJSON_GetObjectItemCaseSensitive(json_key, "message");
89-
if (json_value != NULL) {
89+
if (json_value && json_value->valuestring) {
9090
size_t payload_size = strlen(json_value->valuestring);
9191
data->message = (char*)malloc((payload_size + 1) * sizeof(char));
9292

0 commit comments

Comments
 (0)