framework/st_things : Resolves issues that are not handled after a NULL check
WID:5147823 After having been compared to NULL value, pointer 'json_str' is dereferenced by calling function 'strlen'.
@@ -830,12 +830,7 @@ int parse_things_cloud_json(const char *filename)
if (strlen(json_str) > 0) {
cJSON *root = cJSON_Parse((const char *)json_str);
- if (root == NULL) {
- THINGS_LOG_V(TAG, "cloud file context has a error about json-format.");
- things_free(json_str);
- json_str = NULL;
- return 0;
- }
+ if (root != NULL) {}
cJSON *cloud = cJSON_GetObjectItem(root, KEY_CLOUD);
if (cloud != NULL) {
cJSON *address = cJSON_GetObjectItem(cloud, KEY_CLOUD_ADDRESS);
@@ -846,17 +841,10 @@ int parse_things_cloud_json(const char *filename)
ret = 1;
}
}
- if (root != NULL) {
cJSON_Delete(root);
}
- } else {
- THINGS_LOG_V(TAG, "Can not Read \"%s\" file.", filename);
}
-
- if (json_str != NULL) {
things_free(json_str);
- }
-
THINGS_LOG_D(TAG, THINGS_FUNC_EXIT);
return ret;
}
