Fixed SVACE critical issues 14/100214/1
authorJaechan Lee <jaechan3.lee@samsung.com>
Fri, 25 Nov 2016 08:30:27 +0000 (17:30 +0900)
committerJaechan Lee <jaechan3.lee@samsung.com>
Fri, 25 Nov 2016 08:50:13 +0000 (17:50 +0900)
[Model] Tizen3.0
[BinType] AP
[Customer] OPEN

[Issue#] N/A
[Request] SVACE
[Occurrence Version] N/A

[Problem] MEMORY_LEAK
[Cause & Measure] Cause : src_buffer was not freed in some cases.
Measure : buffer will be freed properly.
[Checking Method] N/A

[Team] MMFW
[Developer] Jaechan Lee
[Solution company] Samsung
[Change Type] N/A

Change-Id: I425f2fc236b2e1fd7dfe8ddcd06d3cd9acceb993

src/mm_player_capture.c

index af6f117..514ab7a 100644 (file)
@@ -279,6 +279,7 @@ __mmplayer_capture_thread(gpointer data)
 {
        mm_player_t* player = (mm_player_t*) data;
        MMMessageParamType msg = {0, };
+       unsigned char * src_buffer = NULL;
        unsigned char * linear_y_plane = NULL;
        unsigned char * linear_uv_plane = NULL;
        int orientation = 0;
@@ -307,7 +308,6 @@ __mmplayer_capture_thread(gpointer data)
                        int linear_uv_plane_size;
                        int width = player->captured.width[0];
                        int height = player->captured.height[0];
-                       unsigned char * src_buffer = NULL;
 
                        linear_y_plane_size = (width * height);
                        linear_uv_plane_size = (width * height / 2);
@@ -357,22 +357,21 @@ __mmplayer_capture_thread(gpointer data)
                } else if (MM_PLAYER_COLORSPACE_NV12 == player->video_cs) {
                        #define MM_ALIGN(x, a)      (((x) +(a) - 1) & ~((a) - 1))
                        int ret = 0;
-                       char *src_buffer = NULL;
                        /* using original width otherwises, app can't know aligned to resize */
                        int width_align = player->captured.width[0];
                        int y_size = width_align * player->captured.height[0];
                        int uv_size = width_align * player->captured.height[1];
                        int src_buffer_size = y_size + uv_size;
                        int i, j;
-                       char*temp = NULL;
-                       char*dst_buf = NULL;
+                       unsigned char * temp = NULL;
+                       unsigned char * dst_buf = NULL;
 
                        if (!src_buffer_size) {
                                LOGE("invalid data size");
                                goto ERROR;
                        }
 
-                       src_buffer = (char*) g_try_malloc(src_buffer_size);
+                       src_buffer = (unsigned char*) g_try_malloc(src_buffer_size);
 
                        if (!src_buffer) {
                                msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
@@ -411,6 +410,9 @@ __mmplayer_capture_thread(gpointer data)
                                LOGE("failed to convert nv12 linear");
                                goto ERROR;
                        }
+
+                       /* clean */
+                       MMPLAYER_FREEIF(src_buffer);
                }
 
                ret = _mmplayer_get_video_rotate_angle((MMHandleType)player, &orientation);
@@ -442,15 +444,13 @@ __mmplayer_capture_thread(gpointer data)
                //MMPLAYER_FREEIF(player->capture.data);
                continue;
 ERROR:
+               MMPLAYER_FREEIF(src_buffer);
+               MMPLAYER_FREEIF(player->captured.data[0]);
+               MMPLAYER_FREEIF(player->captured.data[1]);
                if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED) {
                        /* clean */
                        MMPLAYER_FREEIF(linear_y_plane);
                        MMPLAYER_FREEIF(linear_uv_plane);
-                       MMPLAYER_FREEIF(player->captured.data[0]);
-                       MMPLAYER_FREEIF(player->captured.data[1]);
-               } else if (MM_PLAYER_COLORSPACE_NV12 == player->video_cs) {
-                       MMPLAYER_FREEIF(player->captured.data[0]);
-                       MMPLAYER_FREEIF(player->captured.data[1]);
                }
 
                msg.union_type = MM_MSG_UNION_CODE;