diff --git a/Common/s2j/s2jdef.h b/Common/s2j/s2jdef.h index 7e15737e7..9002b088e 100644 --- a/Common/s2j/s2jdef.h +++ b/Common/s2j/s2jdef.h @@ -52,7 +52,8 @@ typedef struct { #define S2J_STRUCT_GET_STRING_ELEMENT_N(to_struct, from_json, _element, n) \ json_temp = cJSON_GetObjectItem(from_json, #_element); \ - if (json_temp && n > 1) strncpy((to_struct)->_element, json_temp->valuestring, n-1); + if (json_temp && json_temp->valuestring && n > 1)\ + strncpy((to_struct)->_element, json_temp->valuestring, n-1); #define S2J_STRUCT_GET_double_ELEMENT(to_struct, from_json, _element) \ json_temp = cJSON_GetObjectItem(from_json, #_element); \