From c85f50a5769e2a62432454faf208c7c1c49cba3b Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Thu, 3 Mar 2016 17:57:49 +0900 Subject: [PATCH] Fix no unlock defect Change-Id: I94cb41de0e842324577ea1290b73d85110b355db Signed-off-by: Hyunho Kang --- src/message_port.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/message_port.c b/src/message_port.c index 3107b09..4ee9e99 100644 --- a/src/message_port.c +++ b/src/message_port.c @@ -75,8 +75,10 @@ int message_port_register_local_port(const char *local_port, message_port_messag (message_port_callback_item *)g_hash_table_lookup(__listeners, GINT_TO_POINTER(local_port_id)); if (item == NULL) { item = (message_port_callback_item *)calloc(1, sizeof(message_port_callback_item)); - if (item == NULL) + if (item == NULL) { + pthread_mutex_unlock(&__mutex); return MESSAGE_PORT_ERROR_OUT_OF_MEMORY; + } g_hash_table_insert(__listeners, GINT_TO_POINTER(local_port_id), item); } @@ -111,8 +113,10 @@ int message_port_register_trusted_local_port(const char *local_port, message_por (message_port_callback_item *)g_hash_table_lookup(__trusted_listeners, GINT_TO_POINTER(trusted_local_port_id)); if (item == NULL) { item = (message_port_callback_item *)calloc(1, sizeof(message_port_callback_item)); - if (item == NULL) + if (item == NULL) { + pthread_mutex_unlock(&__mutex); return MESSAGE_PORT_ERROR_OUT_OF_MEMORY; + } g_hash_table_insert(__trusted_listeners, GINT_TO_POINTER(trusted_local_port_id), item); } -- 2.7.4