From e2f5dc440589e1c29e5ceae59ea785ff0e512dc7 Mon Sep 17 00:00:00 2001 From: Monsta Date: Wed, 21 Jan 2015 15:25:20 +0300 Subject: fix careless hack: don't do double-free, avoid weird crashes because backends manager frees that var already. actually, adding ev_backends_manager_get_backends_dir to the public API was still careless. backends manager and epub document jobs seem to be in the different threads, and there's no mutex seen anywhere around. luckily, what we have here is just a reading of a variable that has been assigned only once (in backends_dir function), so it's not as catastrophic as it would be if it was e.g. concurrent writing without a mutex. Closes https://github.com/mate-desktop/atril/pull/124 --- libdocument/ev-backends-manager.c | 11 ++--------- libdocument/ev-backends-manager.h | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'libdocument') diff --git a/libdocument/ev-backends-manager.c b/libdocument/ev-backends-manager.c index 74fc09a0..6313b5ee 100644 --- a/libdocument/ev-backends-manager.c +++ b/libdocument/ev-backends-manager.c @@ -63,17 +63,10 @@ backends_dir (void) return backendsdir; } -gchar* +const gchar * ev_backends_manager_get_backends_dir(void) { - gchar *retval; - if (!backendsdir) { - retval = backends_dir(); - } - else { - retval = backendsdir; - } - return retval; + return backends_dir(); } static void diff --git a/libdocument/ev-backends-manager.h b/libdocument/ev-backends-manager.h index 1d660eac..3371a557 100644 --- a/libdocument/ev-backends-manager.h +++ b/libdocument/ev-backends-manager.h @@ -42,7 +42,7 @@ EvDocument *ev_backends_manager_get_document (const gchar *mime_typ const gchar *ev_backends_manager_get_document_module_name (EvDocument *document); EvTypeInfo *ev_backends_manager_get_document_type_info (EvDocument *document); GList *ev_backends_manager_get_all_types_info (void); -gchar *ev_backends_manager_get_backends_dir (void); +const gchar *ev_backends_manager_get_backends_dir (void); G_END_DECLS #endif /* EV_BACKENDS_MANAGER */ -- cgit v1.2.1