Bug fix. add lock for GraphicsMagick function 07/309107/6 accepted/tizen/unified/20240408.160543 accepted/tizen/unified/x/20240409.070659
authorJiyong <jiyong.min@samsung.com>
Thu, 4 Apr 2024 23:27:12 +0000 (08:27 +0900)
committerJiyong <jiyong.min@samsung.com>
Fri, 5 Apr 2024 01:30:45 +0000 (10:30 +0900)
  - DF240401-00513

[Cause]
  The crach occurs during destroying semaphore lock when
  multi-threads are processed(decoding).
  In GraphicsMagick, InitialMagick() & DestroyMagick() functions
  are not thread-safe.

[Solution]
  So locker is added for GraphicsMagick.

Change-Id: Ia19a89dd32994aec5cda5bcdd13acbbf449da947

magick/mm_util_magick.c
packaging/libmm-utility.spec

index 83d82d1..d1eec31 100644 (file)
@@ -26,6 +26,7 @@
 #include "mm_util_private.h"
 #include "mm_util_magick.h"
 
+static GMutex gm_lock;
 
 static bool __mm_util_check_rotation(mm_util_rotate_type_e rotation);
 static void __mm_util_magick_fatal_error_handler(const ExceptionType excep, const char *reason, const char *message) MAGICK_FUNC_NORETURN;
@@ -67,6 +68,8 @@ static void __mm_util_magick_fatal_error_handler(const ExceptionType excep, cons
 
 static void __mm_util_init(ExceptionInfo *exception)
 {
+       g_mutex_lock(&gm_lock);
+
        InitializeMagick(NULL);
        if (exception != NULL)
                GetExceptionInfo(exception);
@@ -98,6 +101,8 @@ static void __mm_util_finalize(Image *image_1, Image *image_2, ExceptionInfo *ex
                DestroyExceptionInfo(exception);
 
        DestroyMagick();
+
+       g_mutex_unlock(&gm_lock);
 }
 
 static const char * __mm_util_get_map(mm_util_color_format_e format)
index b1b7164..acd6165 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.4.20
+Version:    0.4.21
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0