Skip to content
Snippets Groups Projects
Commit 975549e0 authored by Amin Ben Romdhane's avatar Amin Ben Romdhane
Browse files

bbf_plugin: Fix a crash in the synchronize function

parent 08ebe476
Branches
No related tags found
1 merge request!5bbf_plugin: Fix a crash in the synchronize function
Pipeline #119828 passed
...@@ -41,11 +41,16 @@ static int host_get_last_instance(void) ...@@ -41,11 +41,16 @@ static int host_get_last_instance(void)
static void synchronize_hosts_array_with_dmmap(json_object *res) static void synchronize_hosts_array_with_dmmap(json_object *res)
{ {
struct uci_section *s = NULL, *stmp = NULL; struct uci_section *s = NULL, *stmp = NULL;
json_object *hosts_arr = NULL;
char *mac = NULL, *host_mac = NULL; char *mac = NULL, *host_mac = NULL;
bool host_read_idx = false; bool host_read_idx = false;
int host_idx = 0; int host_idx = 0;
size_t nbre_hosts = (res) ? json_object_array_length(res) : 0; if (!res)
return;
json_object_object_get_ex(res, "hosts", &hosts_arr);
int nbre_hosts = (hosts_arr) ? json_object_array_length(hosts_arr) : 0;
uci_path_foreach_sections_safe(bbfdm, "dmmap_hosts", "host", stmp, s) { uci_path_foreach_sections_safe(bbfdm, "dmmap_hosts", "host", stmp, s) {
...@@ -53,7 +58,7 @@ static void synchronize_hosts_array_with_dmmap(json_object *res) ...@@ -53,7 +58,7 @@ static void synchronize_hosts_array_with_dmmap(json_object *res)
if (host_idx < nbre_hosts) { if (host_idx < nbre_hosts) {
if (!host_read_idx) { if (!host_read_idx) {
json_object *host_obj = json_object_array_get_idx(res, host_idx); json_object *host_obj = json_object_array_get_idx(hosts_arr, host_idx);
host_mac = dmjson_get_value(host_obj, 1, "macaddr"); host_mac = dmjson_get_value(host_obj, 1, "macaddr");
host_read_idx = true; host_read_idx = true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment