From 495dbef34079fe860ba0c2cd83a07b086b5a2417 Mon Sep 17 00:00:00 2001 From: Saman Mahmoodi Date: Tue, 16 Feb 2021 16:47:11 +0330 Subject: Fixing pincode problem In get_pincode function there was a problem as below: when the set_pincode verb is not called so in the DB we have not any pincode then for pairing it should use default pincode as 1234 in the get_pincode function when is called read verb from persistence, if pincode does not exist the pincode variable is NULL so we should check the pincode variable and if is NULL, we should assign default value as 1234 Bug-AGL: SPEC-3814 Signed-off-by: Saman Mahmoodi Change-Id: I5f72834d2dcd8ecd3861fc894f4b1a7ebd7efc04 --- binding/bluetooth-api.c | 2 ++ binding/bluetooth-conf.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c index 3fcf841..2bcddd9 100644 --- a/binding/bluetooth-api.c +++ b/binding/bluetooth-api.c @@ -236,6 +236,8 @@ void call_work_destroy_unlocked(struct call_work *cw) g_free(cw->type_arg); g_free(cw->method); g_free(cw->bluez_method); + g_free(cw->agent_data.fixed_pincode); + cw->agent_data.fixed_pincode = NULL; } void call_work_destroy(struct call_work *cw) diff --git a/binding/bluetooth-conf.c b/binding/bluetooth-conf.c index b4dea34..a5824bb 100644 --- a/binding/bluetooth-conf.c +++ b/binding/bluetooth-conf.c @@ -90,8 +90,8 @@ gchar *get_pincode(afb_api_t api) if (json_object_object_get_ex(response, "value", &val)) pincode = g_strdup(json_object_get_string(val)); - else - pincode = "1234"; + if (!pincode) + pincode = g_strdup("1234"); json_object_put(response); return pincode; -- cgit 1.2.3-korg