Fix memory leak in _get_video_size() 37/261437/5 accepted/tizen/6.5/unified/20211028.120848 accepted/tizen/unified/20210726.135508 submit/tizen/20210722.025238 submit/tizen_6.5/20211028.162401 tizen_6.5.m2_release
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 19 Jul 2021 03:15:35 +0000 (12:15 +0900)
committerSangchul Lee <sangchul1011@gmail.com>
Tue, 20 Jul 2021 00:13:58 +0000 (09:13 +0900)
It is revised not to miss to call media_format_unref() in normal case.
Codes to check null parameters are added.
Some codes are refactored.

[Version] 0.0.27
[Issue type] Bug fix

Change-Id: I8a8e4000550ceac4f134121bb2a19579111c5dfe
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/libmm-evas-renderer.spec
src/mm_evas_renderer.c

index 97eba37..0b7f349 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-evas-renderer
 Summary:    Multimedia Framework Evas Renderer Library
-Version:    0.0.26
+Version:    0.0.27
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 8f3bd0c..eb95d2a 100644 (file)
@@ -487,34 +487,40 @@ static void _free_previous_packets(mm_evas_info *evas_info)
        return;
 }
 
-static int _get_video_size(media_packet_h packet, mm_evas_info *evas_info)
+static bool _get_video_size(media_packet_h packet, mm_evas_info *evas_info)
 {
        media_format_h fmt;
+       int w, h;
+       bool ret = true;
 
-       MMER_FENTER();
+       MMEVAS_RETURN_VAL_IF_FAIL(packet, false);
+       MMEVAS_RETURN_VAL_IF_FAIL(evas_info, false);
 
-       if (media_packet_get_format(packet, &fmt) == MEDIA_PACKET_ERROR_NONE) {
-               int w, h;
-               if (media_format_get_video_info(fmt, NULL, &w, &h, NULL, NULL) == MEDIA_PACKET_ERROR_NONE) {
-                       LOGD("video width = %d, height =%d", w, h);
-                       if (w != evas_info->w || h != evas_info->h) {
-                               evas_info->w = w;
-                               evas_info->h = h;
-                               evas_info->rendering_info_changed = TRUE;
-                               evas_info->video_size_changed = TRUE;
-                       }
-                       return true;
-               } else
-                       LOGW("media_format_get_video_info is failed");
-               if (media_format_unref(fmt) != MEDIA_PACKET_ERROR_NONE) /* because of media_packet_get_format */
-                       LOGW("media_format_unref is failed");
-       } else {
-               LOGW("media_packet_get_format is failed");
+       if (media_packet_get_format(packet, &fmt) != MEDIA_PACKET_ERROR_NONE) {
+               LOGE("media_packet_get_format is failed");
+               return false;
        }
 
-       MMER_FLEAVE();
+       if (media_format_get_video_info(fmt, NULL, &w, &h, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE) {
+               LOGE("media_format_get_video_info is failed");
+               ret = false;
+               goto end;
+       }
 
-       return false;
+       if (w != evas_info->w || h != evas_info->h) {
+               LOGD("previous: (%dx%d)", evas_info->w, evas_info->w);
+               evas_info->w = w;
+               evas_info->h = h;
+               evas_info->rendering_info_changed = TRUE;
+               evas_info->video_size_changed = TRUE;
+       }
+       LOGD("(%dx%d)", evas_info->w, evas_info->w);
+
+end:
+       if (media_format_unref(fmt) != MEDIA_FORMAT_ERROR_NONE)
+               LOGW("media_format_unref is failed");
+
+       return ret;
 }
 
 static int _find_empty_index(mm_evas_info *evas_info)