diff options
author | Inkyun Kil <inkyun.kil@samsung.com> | 2022-07-14 16:34:07 +0900 |
---|---|---|
committer | Inkyun Kil <inkyun.kil@samsung.com> | 2022-07-26 09:18:40 +0900 |
commit | 3b669710b71efd9539cd6b8daafcef06c9f5648c (patch) | |
tree | fb25bc53a30df1eda30ac13f1a4f3a15399c844f | |
parent | a032cdc960611512ee914114854923005237f872 (diff) | |
download | libeventsystem-3b669710b71efd9539cd6b8daafcef06c9f5648c.tar.gz libeventsystem-3b669710b71efd9539cd6b8daafcef06c9f5648c.tar.bz2 libeventsystem-3b669710b71efd9539cd6b8daafcef06c9f5648c.zip |
Fix glib critical
- If g_hash_table value is null, it shows glib critical error
Change-Id: Idb18f8306b9e3099dd6221ba7c274078b9612338
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
-rw-r--r-- | src/eventsystem.c | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/src/eventsystem.c b/src/eventsystem.c index 7d4c96e..03b5e7d 100644 --- a/src/eventsystem.c +++ b/src/eventsystem.c @@ -886,6 +886,42 @@ static int __eventsystem_send_trusted_event(GDBusConnection *conn, eventinfo_s * return ES_R_OK; } +static int __update_last_data_item(eventinfo_s *evti, bundle *data) +{ + struct last_data_item *item; + bundle_raw *raw = NULL; + int len; + + if (!last_data_tbl) + return ES_R_OK; + + item = (struct last_data_item *)g_hash_table_lookup(last_data_tbl, + evti->event_name); + if (item == NULL) + return ES_R_OK; + + if (bundle_encode(data, &raw, &len)) { + _E("Unable to encode bundle"); + return ES_R_ERROR; + } + + if (!evti->is_trusted) { + if (item->param) + g_variant_unref(item->param); + item->param = g_variant_new("(us)", len, raw); + } + + if (item->trusted_param) + g_variant_unref(item->trusted_param); + item->trusted_param = g_variant_new("(us)", len, raw); + + bundle_free_encoded_rawdata(&raw); + + _D("Update last data"); + + return ES_R_OK; +} + /** * function : send the user-event */ @@ -894,9 +930,6 @@ API int eventsystem_send_user_event(const char *event_name, bundle *data, { int ret = ES_R_OK; eventinfo_s *evti = NULL; - struct last_data_item *item; - bundle_raw *raw = NULL; - int len; GDBusConnection *conn = NULL; GList *trusted_dest_list = NULL; @@ -948,26 +981,9 @@ API int eventsystem_send_user_event(const char *event_name, bundle *data, evti->is_trusted = is_trusted; if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SESSION, ES_TYPE_USER) == ES_R_OK) { - if (bundle_encode(data, &raw, &len)) { - _E("Unable to encode bundle"); - ret = ES_R_ERROR; + ret = __update_last_data_item(evti, data); + if (ret != ES_R_OK) goto out; - } - - item = (struct last_data_item *)g_hash_table_lookup(last_data_tbl, - evti->event_name); - if (item) { - if (!evti->is_trusted) { - if (item->param) - g_variant_unref(item->param); - item->param = g_variant_new("(us)", len, raw); - } - if (item->trusted_param) - g_variant_unref(item->trusted_param); - item->trusted_param = g_variant_new("(us)", len, raw); - } - - bundle_free_encoded_rawdata(&raw); if (is_trusted) { if (__eventsystem_request_destination_list(evti->event_name, &trusted_dest_list) < 0) { |