summaryrefslogtreecommitdiff
path: root/profiles/health
diff options
context:
space:
mode:
authorTedd Ho-Jeong An <tedd.an@intel.com>2022-02-10 18:00:54 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-02-11 14:17:27 -0800
commit002c0c9eda0052a834ddd4b63026f534b7d52f14 (patch)
tree9013ac179b43941bcd2a6038079b5c93e51afacb /profiles/health
parent8b69a634f4cbd51ec266ee5bb3a9fe77c05e4be4 (diff)
downloadbluez-002c0c9eda0052a834ddd4b63026f534b7d52f14.tar.gz
profiles: Fix the reusing gerror without re-initialization
When the GError variable is freeed with g_error_free(), it is not set to NULL and reusing the same variable again can cause the seg_fault because it is still pointing the old memory address which is freed. This patch relaces the g_error_free() to g_clear_error() which frees the variable and set it to NULL if the variable is used in the function again. Fixes: 4ad622d592ba5 ("profiles/a2dp: Fix unchecked return value")
Diffstat (limited to 'profiles/health')
-rw-r--r--profiles/health/hdp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 40b6cc18a..9d9d1e824 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -576,7 +576,7 @@ static void device_reconnect_mdl_cb(struct mcap_mdl *mdl, GError *err,
"Cannot reconnect: %s", gerr->message);
g_dbus_send_message(conn, reply);
hdp_tmp_dc_data_unref(dc_data);
- g_error_free(gerr);
+ g_clear_error(&gerr);
/* Send abort request because remote side is now in PENDING state */
if (!mcap_mdl_abort(mdl, abort_mdl_cb, NULL, NULL, &gerr)) {
@@ -1766,7 +1766,7 @@ static void device_create_mdl_cb(struct mcap_mdl *mdl, uint8_t conf,
return;
error("%s", gerr->message);
- g_error_free(gerr);
+ g_clear_error(&gerr);
reply = g_dbus_create_reply(hdp_conn->msg,
DBUS_TYPE_OBJECT_PATH, &hdp_chan->path,
@@ -1790,7 +1790,7 @@ fail:
ERROR_INTERFACE ".HealthError",
"%s", gerr->message);
g_dbus_send_message(conn, reply);
- g_error_free(gerr);
+ g_clear_error(&gerr);
/* Send abort request because remote side is now in PENDING */
/* state. Then we have to delete it because we couldn't */