From 183911ce891119292d1ada2464e6fd71a157f023 Mon Sep 17 00:00:00 2001 From: prasadam kumar Date: Thu, 23 Jul 2020 10:50:54 +0530 Subject: [PATCH] Added mutex lock to fix the crash issue Change-Id: Ib5fa112a23c5f23331495eaa6b4a87d01e8a2a41 Signed-off-by: prasadam kumar --- src/libnetwork.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libnetwork.c b/src/libnetwork.c index 8b225e5..a3d9ed8 100755 --- a/src/libnetwork.c +++ b/src/libnetwork.c @@ -171,7 +171,18 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) { bool is_requested = false; connection_error_e result = CONNECTION_ERROR_NONE; - connection_handle_s *conn_handle = (connection_handle_s *)user_data; + CONN_LOCK; + connection_handle_s conn_handle_local; + connection_handle_s *conn_handle = &conn_handle_local; + connection_handle_s *conn_handle_origin = (connection_handle_s *)user_data; + + if(!_connection_check_handle_validity(conn_handle_origin)) { + CONNECTION_LOG(CONNECTION_INFO, "Invalid handle"); + CONN_UNLOCK; + return; + } + memcpy(conn_handle, conn_handle_origin, sizeof(connection_handle_s)); + CONN_UNLOCK; switch (event_cb->Event) { case NET_EVENT_OPEN_RSP: -- 2.7.4