diff options
author | Hyunho Kang <hhstark.kang@samsung.com> | 2016-08-31 13:40:46 +0900 |
---|---|---|
committer | Hyunho Kang <hhstark.kang@samsung.com> | 2016-08-31 13:45:26 +0900 |
commit | b33769a51244c1662bac1a3268a3862b7bff8db9 (patch) | |
tree | b280a41564217b4fd5c1ac1b2e45c43d121c2ee9 | |
parent | 8e40fb8b217abcba5b4e3e0a9c4830a1bdd6f521 (diff) | |
download | message-port-b33769a51244c1662bac1a3268a3862b7bff8db9.tar.gz message-port-b33769a51244c1662bac1a3268a3862b7bff8db9.tar.bz2 message-port-b33769a51244c1662bac1a3268a3862b7bff8db9.zip |
Add NULL check logic for message callback
Change-Id: I6a0241ec2364e8b9eac0d8a0b56fe7067d733da8
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rw-r--r-- | src/message_port.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/message_port.c b/src/message_port.c index b6d22e7..971e829 100644 --- a/src/message_port.c +++ b/src/message_port.c @@ -42,16 +42,23 @@ static void do_callback(message_port_message_cb callback, int local_port_id, con static void message_dispatcher(int local_port_id, const char *remote_app_id, const char *remote_port, bool trusted_remote_port, bundle *message, void *user_data) { - message_port_callback_item *item = - (message_port_callback_item *)g_hash_table_lookup(__listeners, GINT_TO_POINTER(local_port_id)); - do_callback(item->callback, local_port_id, remote_app_id, remote_port, trusted_remote_port, message, item->user_data); + message_port_callback_item *item = NULL; + if (__listeners == NULL) + return; + item = (message_port_callback_item *)g_hash_table_lookup(__listeners, GINT_TO_POINTER(local_port_id)); + if (item != NULL) + do_callback(item->callback, local_port_id, remote_app_id, remote_port, trusted_remote_port, message, item->user_data); } static void trusted_message_dispatcher(int trusted_local_port_id, const char *remote_app_id, const char *remote_port, bool trusted_remote_port, bundle *message, void *user_data) { - message_port_callback_item *item = - (message_port_callback_item *)g_hash_table_lookup(__trusted_listeners, GINT_TO_POINTER(trusted_local_port_id)); - do_callback(item->callback, trusted_local_port_id, remote_app_id, remote_port, trusted_remote_port, message, item->user_data); + message_port_callback_item *item = NULL; + + if (__trusted_listeners == NULL) + return; + item = (message_port_callback_item *)g_hash_table_lookup(__trusted_listeners, GINT_TO_POINTER(trusted_local_port_id)); + if (item != NULL) + do_callback(item->callback, trusted_local_port_id, remote_app_id, remote_port, trusted_remote_port, message, item->user_data); } int message_port_register_local_port(const char *local_port, message_port_message_cb callback, void *user_data) |