mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
d/opengloves: Fix leak of config JSON
This commit is contained in:
parent
1e639fc2f3
commit
2673787429
|
@ -33,15 +33,15 @@
|
|||
|
||||
|
||||
static const cJSON *
|
||||
opengloves_load_config_file(struct u_config_json config_json)
|
||||
opengloves_load_config_file(struct u_config_json *config_json)
|
||||
{
|
||||
u_config_json_open_or_create_main_file(&config_json);
|
||||
if (!config_json.file_loaded) {
|
||||
u_config_json_open_or_create_main_file(config_json);
|
||||
if (!config_json->file_loaded) {
|
||||
OPENGLOVES_ERROR("Failed to load config file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const cJSON *out_config_json = u_json_get(config_json.root, "config_opengloves");
|
||||
const cJSON *out_config_json = u_json_get(config_json->root, "config_opengloves");
|
||||
if (out_config_json == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -78,7 +78,11 @@ opengloves_create_devices(struct xrt_device **out_xdevs, const struct xrt_system
|
|||
|
||||
// load config
|
||||
struct u_config_json config_json = {0};
|
||||
const cJSON *opengloves_config_json = opengloves_load_config_file(config_json);
|
||||
const cJSON *opengloves_config_json = opengloves_load_config_file(&config_json);
|
||||
if (opengloves_config_json == NULL) {
|
||||
cJSON_Delete(config_json.root);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// set up tracking overrides
|
||||
int cur_dev = 0;
|
||||
|
@ -112,5 +116,7 @@ opengloves_create_devices(struct xrt_device **out_xdevs, const struct xrt_system
|
|||
out_xdevs[cur_dev++] = dev_wrap;
|
||||
}
|
||||
|
||||
cJSON_Delete(config_json.root);
|
||||
|
||||
return cur_dev;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue