summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSemun Lee <sm79.lee@samsung.com>2016-07-05 21:10:15 +0900
committerSemun Lee <sm79.lee@samsung.com>2016-07-05 23:53:11 -0700
commit23b6e1e14ab47dc9eaf289f3e7b99a7b0e81974a (patch)
tree2bb1722b38e1b82d951d4d6dca29b2292392c8c1
parentecf71b452b6f8a589ce3b2f6debda2ae792add77 (diff)
downloadbadge-23b6e1e14ab47dc9eaf289f3e7b99a7b0e81974a.tar.gz
badge-23b6e1e14ab47dc9eaf289f3e7b99a7b0e81974a.tar.bz2
badge-23b6e1e14ab47dc9eaf289f3e7b99a7b0e81974a.zip
static variable may cause crash in g_dbus_error_register_error_domain when the badge module is unloaded by ui-gadget Change-Id: Id62d8b7d5f11a2e179b4fa3503e5cdbc91c3af64 Signed-off-by: Semun Lee <sm79.lee@samsung.com>
-rw-r--r--src/badge_error.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/badge_error.c b/src/badge_error.c
index 141dc55..dcfba0f 100644
--- a/src/badge_error.c
+++ b/src/badge_error.c
@@ -17,6 +17,7 @@
*
*/
+#include <string.h>
#include <gio/gio.h>
#include "badge_error.h"
@@ -33,10 +34,26 @@ static const GDBusErrorEntry dbus_error_entries[] = {
{BADGE_ERROR_INVALID_PACKAGE, "org.freedesktop.Badge.Error.INVALID_PACKAGE"},
};
+#define BADGE_ERROR_QUARK "badge-error-quark"
+
EXPORT_API GQuark badge_error_quark(void)
{
static volatile gsize quark_volatile = 0;
- g_dbus_error_register_error_domain("badge-error-quark",
+ static 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(BADGE_ERROR_QUARK);
+
+ if (quark == 0) {
+ if (domain_name == NULL)
+ domain_name = strdup(BADGE_ERROR_QUARK);
+ } else {
+ domain_name = BADGE_ERROR_QUARK;
+ }
+
+ g_dbus_error_register_error_domain(domain_name,
&quark_volatile,
dbus_error_entries,
G_N_ELEMENTS(dbus_error_entries));