mirror of
https://github.com/emqx/neuron.git
synced 2026-10-28 22:59:34 +08:00
fix(modbus): free invalid memory
This commit is contained in:
@@ -144,7 +144,9 @@ static int driver_config(neu_plugin_t *plugin, const char *config)
|
||||
char * err_param = NULL;
|
||||
neu_json_elem_t port = { .name = "port", .t = NEU_JSON_INT };
|
||||
neu_json_elem_t timeout = { .name = "timeout", .t = NEU_JSON_INT };
|
||||
neu_json_elem_t host = { .name = "host", .t = NEU_JSON_STR };
|
||||
neu_json_elem_t host = { .name = "host",
|
||||
.t = NEU_JSON_STR,
|
||||
.v.val_str = NULL };
|
||||
neu_json_elem_t interval = { .name = "interval", .t = NEU_JSON_INT };
|
||||
neu_json_elem_t mode = { .name = "connection_mode", .t = NEU_JSON_INT };
|
||||
neu_json_elem_t tmode = { .name = "transport_mode", .t = NEU_JSON_INT };
|
||||
@@ -159,7 +161,9 @@ static int driver_config(neu_plugin_t *plugin, const char *config)
|
||||
if (ret != 0) {
|
||||
plog_error(plugin, "config: %s, decode error: %s", config, err_param);
|
||||
free(err_param);
|
||||
free(host.v.val_str);
|
||||
if (host.v.val_str != NULL) {
|
||||
free(host.v.val_str);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user