From f56190a6b8b43009658728b1a1e8a48a0a290a9a Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Tue, 7 Apr 2020 16:17:22 +0900 Subject: Prevent segmentaion fault when invoking callback function --- src/wifi-aware-data-path.c | 3 ++- src/wifi-aware-private.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/wifi-aware-data-path.c b/src/wifi-aware-data-path.c index 9a953c7..949f9aa 100644 --- a/src/wifi-aware-data-path.c +++ b/src/wifi-aware-data-path.c @@ -216,9 +216,10 @@ static void __data_path_invoke_callback(wifi_aware_data_path_h data_path, wifi_a wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path; if (ndp->open_cb) { - ndp->open_cb(data_path, error, ndp->open_cb_user_data); + wifi_aware_data_path_open_cb open_cb = ndp->open_cb; ndp->open_cb = NULL; ndp->open_cb_user_data = NULL; + open_cb(data_path, error, ndp->open_cb_user_data); } } diff --git a/src/wifi-aware-private.c b/src/wifi-aware-private.c index 4da7288..fed3294 100644 --- a/src/wifi-aware-private.c +++ b/src/wifi-aware-private.c @@ -239,9 +239,10 @@ static void __enable_request_reply(GObject *src, GAsyncResult *res, gpointer use } if (g_wifi_aware->enabled_cb) { - g_wifi_aware->enabled_cb(error, g_wifi_aware->enabled_cb_data); + wifi_aware_enabled_cb enabled_cb = g_wifi_aware->enabled_cb; g_wifi_aware->enabled_cb = NULL; g_wifi_aware->enabled_cb_data = NULL; + enabled_cb(error, g_wifi_aware->enabled_cb_data); } } @@ -272,9 +273,10 @@ static void __wifi_aware_publish_invoke_callback(wifi_aware_session_h session, wifi_aware_session_s *handle = (wifi_aware_session_s *)session; if (handle->published_cb) { - handle->published_cb(session, error, handle->published_cb_data); + wifi_aware_published_cb published_cb = handle->published_cb; handle->published_cb = NULL; handle->published_cb_data = NULL; + published_cb(session, error, handle->published_cb_data); } } @@ -370,9 +372,10 @@ static void __wifi_aware_subscribe_invoke_callback(wifi_aware_session_h session, wifi_aware_session_s *handle = (wifi_aware_session_s *)session; if (handle->subscribed_cb) { - handle->subscribed_cb(session, error, handle->subscribed_cb_data); + wifi_aware_subscribed_cb subscribed_cb = handle->subscribed_cb; handle->subscribed_cb = NULL; handle->subscribed_cb_data = NULL; + subscribed_cb(session, error, handle->subscribed_cb_data); } } -- cgit v1.2.3