From a5b74400fb64f0afd4adf8fd3619085085ec1233 Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Fri, 7 Jan 2022 13:08:41 +0530 Subject: [PATCH] Fix Svace Issues This patch fixes scave issues: 473071: DIVISION_BY_ZERO 473376: MEMORY_LEAK Change-Id: I8818accf1d7ff5a5b8adbbd2311e82d292f9b568 Signed-off-by: Anuj Jain --- bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c | 6 +++++- bt-service/services/obex/bt-service-opp-client.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c index a1adb11..523f5c2 100644 --- a/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c @@ -1503,14 +1503,18 @@ static struct l_dbus_message *__mesh_agent_display_numeric_request( INFO("Mesh:[OUT] Numeric Authentication type [%s] value [%u]", str, n); auth_value = l_strdup_printf("%u", n); ev.auth_type = __mesh_get_authentication_type(str); - if (ev.auth_type == BT_HAL_MESH_UNKNOWN_AUTH_METHOD) + if (ev.auth_type == BT_HAL_MESH_UNKNOWN_AUTH_METHOD) { + l_free(auth_value); + g_free(net_uuid); return l_dbus_message_new_error(msg, dbus_err_fail, NULL); + } g_strlcpy(ev.auth_value, auth_value, sizeof(ev.auth_value)); if (mesh_event_cb) mesh_event_cb(HAL_EV_MESH_AUTHENTICATION_REQUEST, (void*)&ev, sizeof(ev)); + l_free(auth_value); g_free(net_uuid); return l_dbus_message_new_method_return(msg); diff --git a/bt-service/services/obex/bt-service-opp-client.c b/bt-service/services/obex/bt-service-opp-client.c index 8df2e3c..0d9aff2 100755 --- a/bt-service/services/obex/bt-service-opp-client.c +++ b/bt-service/services/obex/bt-service-opp-client.c @@ -155,7 +155,11 @@ gboolean _bt_obex_client_progress(const char *transfer_path, guint64 transferred sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_PROGRESS; sending_info->result = result; - previous_progress = (int)(((gdouble)sending_info->transfer_info->progress /(gdouble)size) * 100); + if (size != 0) + previous_progress = (int)(((gdouble)sending_info->transfer_info->progress /(gdouble)size) * 100); + else + previous_progress = 0; + if (percentage_progress == previous_progress && sending_info->transfer_info->progress) { sending_info->transfer_info->progress = transferred; -- 2.7.4