X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-v3.c;h=02853b1283ebf5005117d5e511a89b30f27da3c3;hb=9c2e6e45d4c9745c4702ac1992a0cb086e99fb0b;hp=5134c96f9991f32a4e26143a7f75380b039f0c4a;hpb=8ca7b69f3e3145f4c08bdbd278f200f6f8868d74;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-v3.c b/src/afb-api-v3.c index 5134c96f..02853b12 100644 --- a/src/afb-api-v3.c +++ b/src/afb-api-v3.c @@ -135,9 +135,9 @@ static struct json_object *describe_verb_v3(const struct afb_verb_v3 *verb) a = json_object_new_object(); json_object_object_add(g, "responses", a); - f = json_object_new_object(); - json_object_object_add(a, "200", f); - json_object_object_add(f, "description", json_object_new_string(verb->info?:verb->verb)); + g = json_object_new_object(); + json_object_object_add(a, "200", g); + json_object_object_add(g, "description", json_object_new_string(verb->info?:verb->verb)); return f; } @@ -194,8 +194,10 @@ struct afb_api_v3 *afb_api_v3_create( /* allocates the description */ api = calloc(1, sizeof *api + (copy_info && info ? 1 + strlen(info) : 0)); - if (!api) + if (!api) { + ERROR("out of memory"); goto oom; + } api->refcount = 1; if (!info) api->info = &nulchar; @@ -223,7 +225,6 @@ oom3: oom2: free(api); oom: - ERROR("out of memory"); return NULL; } @@ -238,6 +239,9 @@ void afb_api_v3_unref(struct afb_api_v3 *api) { if (api && !__atomic_sub_fetch(&api->refcount, 1, __ATOMIC_RELAXED)) { afb_export_destroy(api->export); + while (api->count) + free(api->verbs[--api->count]); + free(api->verbs); free(api); } }