From: Atul Rai Date: Mon, 18 Jun 2018 10:16:24 +0000 (+0530) Subject: [HAL]Add NULL check before calling g_variant_unref X-Git-Tag: accepted/tizen/unified/20180620.131458~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git;a=commitdiff_plain;h=affd32489f9ad6c6c6e8f7b3360af4da7a66d9d5 [HAL]Add NULL check before calling g_variant_unref Change-Id: I6830b7c305ec696e8cbd3aed95a5e9db77a72e5a Signed-off-by: Atul Rai --- diff --git a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c index 76223ea..0c6077a 100644 --- a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c +++ b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c @@ -465,7 +465,7 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg) DBG("Send Adapter properties changed event to HAL user, Num Prop [%d] total size [%d]", ev->num_props, size); event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, buf, size); } - g_variant_unref(value); + DBG("-"); } @@ -608,7 +608,7 @@ static gboolean __bt_hal_parse_device_properties(GVariant *item) DBG("Device Name [%s] Property num [%d]", name, ev->num_props); } } else if (strcasecmp(key, "Connected") == 0) { - unsigned int connected = g_variant_get_uint32(val); + unsigned int connected = g_variant_get_byte(val); size += __bt_insert_hal_properties(buf + size, HAL_PROP_DEVICE_CONNECTED, sizeof(unsigned int), &connected); @@ -1569,7 +1569,8 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) size += __bt_insert_hal_properties(buf + size, HAL_PROP_DEVICE_CLASS, sizeof(unsigned int), &class); ev->num_props++; - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); /* Connected */ @@ -1579,7 +1580,8 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) sizeof(unsigned int), &connected); ev->num_props++; DBG("Device connected [%u] Property num [%d]", connected, ev->num_props); - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); /* Trust */ tmp_value = g_variant_lookup_value(value, "Trusted", G_VARIANT_TYPE_BOOLEAN); @@ -1588,7 +1590,8 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) sizeof(uint8_t), &trust); ev->num_props++; DBG("Device trusted [%d] Property num [%d]", trust, ev->num_props); - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); /* Paired */ tmp_value = g_variant_lookup_value(value, "Paired", G_VARIANT_TYPE_BOOLEAN); @@ -1598,7 +1601,8 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) sizeof(uint8_t), &paired); ev->num_props++; DBG("Device Paired [%d] Property num [%d]", paired, ev->num_props); - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); /* RSSI*/ tmp_value = g_variant_lookup_value(value, "RSSI", G_VARIANT_TYPE_INT32); @@ -1607,12 +1611,14 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) sizeof(int), &rssi); ev->num_props++; DBG("Device RSSI [%d] Property num [%d]", rssi, ev->num_props); - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); /* Last Addr Type */ tmp_value = g_variant_lookup_value(value, "LastAddrType", G_VARIANT_TYPE_UINT32); unsigned int addr_type = tmp_value ? g_variant_get_uint32(tmp_value) : 0; - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); DBG("Device Last Address Type [0x%x]", addr_type); /* Is Alias Set */ @@ -1622,7 +1628,8 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) sizeof(uint8_t), &is_alias_set); ev->num_props++; DBG("IsAliasSet: [%s], Property num [%d]", (is_alias_set ? "TRUE" : "FALSE"), ev->num_props); - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); /* UUID's */ tmp_value = g_variant_lookup_value(value, "UUIDs", G_VARIANT_TYPE_STRING_ARRAY); @@ -1673,7 +1680,8 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) ERR("manufacturer_data_len is too long(len = %d)", manufacturer_data_len); manufacturer_data_len = BT_HAL_MANUFACTURER_DATA_LENGTH_MAX; } - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); /*size += __bt_insert_hal_properties(buf + size, HAL_PROP_DEVICE_MANUFACTURER_DATA_LEN, sizeof(unsigned int), &manufacturer_data_len); ev->num_props++;*/ @@ -1690,7 +1698,8 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) ev->num_props++; } } - g_variant_unref(tmp_value); + if (tmp_value) + g_variant_unref(tmp_value); /* Address */ uint8_t bdaddr[6];