Remove memory allocation in signal handler to avoid deadlock 22/116022/1
authorSeungbae Shin <seungbae.shin@samsung.com>
Wed, 22 Feb 2017 11:24:53 +0000 (20:24 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Wed, 22 Feb 2017 11:26:11 +0000 (20:26 +0900)
[Version] 0.2.10
[Profile] Common
[Issue Type] Enhance

Change-Id: I8f76eba6830dd040424db38efbb8ae4684c7020f

mm_session.c
packaging/libmm-session.spec

index 6efb5a7..69d3ec7 100644 (file)
@@ -28,7 +28,6 @@
 #include <mm_error.h>
 #include <mm_debug.h>
 #include <errno.h>
-#include <glib.h>
 #include <pthread.h>
 #include <signal.h>
 
@@ -466,7 +465,7 @@ int _mm_session_util_read_information(int app_pid, int *session_type, int *flags
 
 void __session_signal_handler(int signo)
 {
-       char* filename = NULL;
+       char filename[MAX_FILE_LENGTH];
        char str_error[256];
 
        debug_warning("ENTER, sig.num(%d)", signo);
@@ -476,16 +475,14 @@ void __session_signal_handler(int signo)
        sigfillset(&all_mask);
        sigprocmask(SIG_BLOCK, &all_mask, &old_mask);
 
-       filename = g_strdup_printf("/tmp/mm_session_%d", getpid());
+       snprintf(filename, sizeof(filename) - 1, "/tmp/mm_session_%d", getpid());
        if (!remove(filename)) {
                debug_log(" remove %s success\n", filename);
        } else {
-               strerror_r (errno, str_error, sizeof (str_error));
+               strerror_r(errno, str_error, sizeof(str_error));
                debug_error(" remove %s failed with %s\n", filename, str_error);
        }
 
-       g_free(filename);
-
        sigprocmask(SIG_SETMASK, &old_mask, NULL);
        /* signal unblock ------------ */
 
index b1935f5..375bdda 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-session
 Summary:    Multimedia Session Library
-Version:    0.2.9
+Version:    0.2.10
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0