Fixed Segfault #9
This commit is contained in:
@@ -82,10 +82,11 @@ int getRestSensor(sensor *sensor) {
|
||||
//The ID is stored in the JSON root
|
||||
cJSON *id = cJSON_GetObjectItemCaseSensitive(jsondata, "id");
|
||||
|
||||
sensor->temperature = (float)temperature->valuedouble;
|
||||
sensor->humidity = (float)humidity->valuedouble;
|
||||
sensor->node_id = atoi(id->valuestring);
|
||||
|
||||
if (temperature != NULL && humidity != NULL && id != NULL) {
|
||||
sensor->temperature = (float)temperature->valuedouble;
|
||||
sensor->humidity = (float)humidity->valuedouble;
|
||||
sensor->node_id = atoi(id->valuestring);
|
||||
}
|
||||
//free
|
||||
cJSON_Delete(jsondata);
|
||||
free(data);
|
||||
|
Reference in New Issue
Block a user