From: Semun Lee Date: Tue, 5 Jul 2016 12:06:43 +0000 (+0900) Subject: Fix crash when ui-gadget unloads notification module X-Git-Tag: submit/tizen/20160706.043533 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=66555081a205f928dd9487967ec365fafd43f51b;p=platform%2Fcore%2Fapi%2Fnotification.git Fix crash when ui-gadget unloads notification module static variables may cause crash in g_dbus_error_register_error_domain Change-Id: Iedf10f2998d4fa8bd296359c093c9af2fa93bcbc Signed-off-by: Semun Lee --- diff --git a/src/notification_error.c b/src/notification_error.c index deceec5..40ed959 100644 --- a/src/notification_error.c +++ b/src/notification_error.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include "notification_error.h" @@ -30,10 +31,26 @@ static const GDBusErrorEntry dbus_error_entries[] = { {NOTIFICATION_ERROR_INVALID_OPERATION, "org.freedesktop.Notification.Error.INVALID_OPERATION"}, }; +#define NOTIFICATION_ERROR_QUARK "notification-error-quark" + EXPORT_API GQuark notification_error_quark(void) { static volatile gsize quark_volatile = 0; - g_dbus_error_register_error_domain("notification-error-quark", + static const char *domain_name = NULL; + + /* This is for preventing crash when notification api is used in ui-gadget */ + /* ui-gadget libraries can be unloaded when it is needed and the static string */ + /* parameter to g_dbus_error_register_error_domain may cause crash. */ + GQuark quark = g_quark_try_string(NOTIFICATION_ERROR_QUARK); + + if (quark == 0) { + if (domain_name == NULL) + domain_name = strdup(NOTIFICATION_ERROR_QUARK); + } else { + domain_name = NOTIFICATION_ERROR_QUARK; + } + + g_dbus_error_register_error_domain(domain_name, &quark_volatile, dbus_error_entries, G_N_ELEMENTS(dbus_error_entries));