Fix SVACE defects 74/68274/2
authorMok Jeongho <jho.mok@samsung.com>
Tue, 3 May 2016 07:32:07 +0000 (16:32 +0900)
committerMok Jeongho <jho.mok@samsung.com>
Tue, 3 May 2016 08:03:40 +0000 (17:03 +0900)
[Version] Release 0.10.28
[Profile] Common
[Issue Type] Code Enhancement

Change-Id: I75f6c7f194a17b77ac15f23e2c3c754bd94d0c03

common/mm_sound_dbus.c
mm_sound_client.c
packaging/libmm-sound.spec

index a55a56f..580aac5 100644 (file)
@@ -476,7 +476,11 @@ int mm_sound_dbus_signal_subscribe_to(audio_provider_t provider, audio_event_t e
                return MM_ERROR_SOUND_INTERNAL;
        }
 
-       cb_data = (struct callback_data*) g_malloc0(sizeof(struct callback_data));
+       if (!(cb_data = (struct callback_data*) g_malloc0(sizeof(struct callback_data)))) {
+               debug_error("Allocate for callback data failed");
+               return MM_ERROR_SOUND_INTERNAL;
+       }
+
        cb_data->user_cb = callback;
        cb_data->user_data = userdata;
        cb_data->free_func = freefunc;
@@ -492,8 +496,7 @@ int mm_sound_dbus_signal_subscribe_to(audio_provider_t provider, audio_event_t e
        return MM_ERROR_NONE;
 
 fail:
-       if (cb_data)
-               free(cb_data);
+       free(cb_data);
        return MM_ERROR_SOUND_INTERNAL;
 }
 
index b3fe160..fe01108 100644 (file)
@@ -381,7 +381,7 @@ int mm_sound_client_play_tone_with_stream_info(int tone, char *stream_type, int
 static void _mm_sound_stop_callback_wrapper_func(int ended_handle, void *userdata)
 {
        struct callback_data *cb_data = (struct callback_data*) userdata;
-       play_sound_end_callback_data_t *end_cb_data = (play_sound_end_callback_data_t*) cb_data->extra_data;
+       play_sound_end_callback_data_t *end_cb_data;
 
        debug_log("[Wrapper CB][Play Stop] ended_handle : %d", ended_handle);
 
@@ -389,6 +389,9 @@ static void _mm_sound_stop_callback_wrapper_func(int ended_handle, void *userdat
                debug_warning("stop callback data null");
                return;
        }
+
+       end_cb_data = (play_sound_end_callback_data_t*) cb_data->extra_data;
+
        if (ended_handle == end_cb_data->watching_handle) {
                debug_log("Interested playing handle end : %d", ended_handle);
                ((mm_sound_stop_callback_func)(cb_data->user_cb))(cb_data->user_data, ended_handle);
@@ -642,7 +645,7 @@ static void _mm_sound_device_connected_callback_wrapper_func(int device_id, cons
 {
        mm_sound_device_t device_h;
        struct callback_data *cb_data = (struct callback_data*) userdata;
-       int device_flags = (int) cb_data->extra_data;
+       int device_flags;
 
        debug_log("[Wrapper CB][Device Connnected] device_id : %d, device_type : %s, direction : %d, state : %d, name : %s, is_connected : %d",
                          device_id, device_type, io_direction, state, name, is_connected);
@@ -651,6 +654,9 @@ static void _mm_sound_device_connected_callback_wrapper_func(int device_id, cons
                debug_warning("device connected changed callback data null");
                return;
        }
+
+       device_flags = (int) cb_data->extra_data;
+
        if (!is_device_match_flags(device_type, io_direction, state, device_flags))
                return;
 
@@ -695,7 +701,7 @@ static void _mm_sound_device_info_changed_callback_wrapper_func(int device_id, c
 {
        mm_sound_device_t device_h;
        struct callback_data *cb_data = (struct callback_data*) userdata;
-       int device_flags = (int) cb_data->extra_data;
+       int device_flags;
 
        debug_log("[Wrapper CB][Device Info Changed] device_id : %d, device_type : %s, direction : %d, state : %d, name : %s, changed_info_type : %d",
                          device_id, device_type, io_direction, state, name, changed_device_info_type);
@@ -704,6 +710,9 @@ static void _mm_sound_device_info_changed_callback_wrapper_func(int device_id, c
                debug_warning("device info changed callback data null");
                return;
        }
+
+       device_flags = (int) cb_data->extra_data;
+
        if (!is_device_match_flags(device_type, io_direction, state, device_flags))
                return;
 
index e1a698d..813366a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.27
+Version:    0.10.28
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0