commit a1c776dd13ef4d9d3b3dc2ed3d25f8f478c9a27f from: the xhr date: Thu Sep 16 12:14:28 2021 UTC Be more careful when opening oracle JSONs commit - fc6936c9e0f166ad38902a6d7e68571f109129ba commit + a1c776dd13ef4d9d3b3dc2ed3d25f8f478c9a27f blob - 91a8779dd612ffeb72a140d5f5a8978d1d731b30 blob + 7cf47e144675e585c282ee0fd081af37fc6b4e77 --- oracle.c +++ oracle.c @@ -186,7 +186,11 @@ read_names_from_json() log_errx(1, "Cannot open %s\n", path); } - oracles = json_object_object_get(root, "Oracles"); + if (!json_object_object_get_ex(root, "Oracles", &oracles)) { + log_debug("Cannot find a [Oracles] array in %s\n", path); + return; + } + n_oracles = json_object_array_length(oracles); log_debug("number of oracles: %d\n", n_oracles); @@ -237,7 +241,11 @@ read_moves_from_json() log_errx(1, "Cannot open %s\n", path); } - oracles = json_object_object_get(root, "Oracles"); + if (!json_object_object_get_ex(root, "Oracles", &oracles)) { + log_debug("Cannot find a [Oracles] array in %s\n", path); + return; + } + n_oracles = json_object_array_length(oracles); log_debug("number of oracles: %d\n", n_oracles); @@ -282,7 +290,11 @@ read_action_from_json() log_errx(1, "Cannot open %s\n", path); } - oracles = json_object_object_get(root, "Oracles"); + if (!json_object_object_get_ex(root, "Oracles", &oracles)) { + log_debug("Cannot find a [Oracles] array in %s\n", path); + return; + } + n_oracles = json_object_array_length(oracles); log_debug("number of oracles: %d\n", n_oracles); @@ -336,7 +348,11 @@ read_turning_from_json() log_errx(1, "Cannot open %s\n", path); } - oracles = json_object_object_get(root, "Oracles"); + if (!json_object_object_get_ex(root, "Oracles", &oracles)) { + log_debug("Cannot find a [Oracles] array in %s\n", path); + return; + } + n_oracles = json_object_array_length(oracles); log_debug("number of oracles: %d\n", n_oracles); @@ -385,7 +401,11 @@ read_places_from_json() log_errx(1, "Cannot open %s\n", path); } - oracles = json_object_object_get(root, "Oracles"); + if (!json_object_object_get_ex(root, "Oracles", &oracles)) { + log_debug("Cannot find a [Oracles] array in %s\n", path); + return; + } + n_oracles = json_object_array_length(oracles); log_debug("number of oracles: %d\n", n_oracles);