Fix static analysis 23/277223/1
authorInkyun Kil <inkyun.kil@samsung.com>
Mon, 4 Jul 2022 02:55:39 +0000 (11:55 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Mon, 4 Jul 2022 02:55:59 +0000 (11:55 +0900)
Change-Id: I3c92904c5da7b1746c4998d041313f041367b641
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
lib/alarm-lib.c

index 7c22c84..7396c3e 100644 (file)
@@ -386,8 +386,10 @@ static void __bus_get_for_async_api(GObject *source_object, GAsyncResult *res,
 
        alarm_context.connection = g_bus_get_finish(res, &error);
        if (!alarm_context.connection) {
-               LOGE("dbus error message: %s", error->message);
-               g_error_free(error);
+               if (error) {
+                       LOGE("dbus error message: %s", error->message);
+                       g_error_free(error);
+               }
                g_variant_unref(param->v);
                g_free(param);
                pthread_mutex_unlock(&init_lock);
@@ -440,8 +442,10 @@ static int __sub_init()
 
        alarm_context.connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
        if (alarm_context.connection == NULL) {
-               LOGE("g_bus_get_sync() is failed. error: %s", error->message);
-               g_error_free(error);
+               if (error) {
+                       LOGE("g_bus_get_sync() is failed. error: %s", error->message);
+                       g_error_free(error);
+               }
                pthread_mutex_unlock(&init_lock);
                return ERR_ALARM_SYSTEM_FAIL;
        }