Fix Svace issue 70/252570/1 accepted/tizen/unified/20210204.134622 submit/tizen/20210129.111611 submit/tizen/20210202.082659 submit/tizen/20210203.050031
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 29 Jan 2021 10:00:37 +0000 (19:00 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 29 Jan 2021 10:00:37 +0000 (19:00 +0900)
- UNUSED_RETURN_VALUE
- DEREF_OF_NULL.EX

[Version] 0.1.32
[Issue Type] Svace

Change-Id: I1e4728e8a953fa41cb7ae7fec365bd35952138dd
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/capi-media-tool.spec
src/media_packet.c
test/media_packet_test.c

index 641bd963f4702dad113ccfeb242cb57b6ee6411a..86a5d8fa9be068d503189447848d25e6acb41e90 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-tool
 Summary:    A Core API media tool library in Tizen Native API
-Version:    0.1.31
+Version:    0.1.32
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index e14cbe721f047629271a36a24374d001e8294b41..8674775893717ea79b86a124b82e56b61a8f00a9 100644 (file)
@@ -78,7 +78,10 @@ static int __pkt_init(media_buffer_type_e type, media_format_h fmt,
 
 static void __pkt_deinit(media_packet_s *handle)
 {
-       MEDIA_PACKET_NULL_ARG_CHECK(handle);
+       if (!handle) {
+               LOGW("NULL handle");
+               return;
+       }
 
        media_format_unref(handle->format);
        handle->format = NULL;
index 078b97a52279c24343c68c8815d743da87ccfeb0..ed013cd3c12d5eabab08a236aab815681387767d 100644 (file)
@@ -518,7 +518,10 @@ static void _media_packet_destroy()
 
        for (i = 0; i < g_handle_num; i++) {
                if (g_media_packet[i] != NULL) {
-                       ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                       if (g_media_format[media_format_idx])
+                               ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                       else
+                               ref_count = -1;
                        ret = media_packet_destroy(g_media_packet[i]);
                        g_media_packet[i] = NULL;
 
@@ -883,7 +886,10 @@ void quit_program(void)
 
        for (i = 0; i < g_handle_num; i++) {
                if (g_media_packet[i] != NULL) {
-                       ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                       if (g_media_format[media_format_idx])
+                               ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                       else
+                               ref_count = -1;
                        media_packet_destroy(g_media_packet[i]);
                        g_media_packet[i] = NULL;
                        if (ref_count == 1) {
@@ -895,7 +901,7 @@ void quit_program(void)
 
        for (i = 0; i < MEDIA_FORMAT_MAX_HANDLE; i++) {
                if (g_media_format[i] != NULL) {
-                       int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[i]);
+                       ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[i]);
                        g_print("media_format_h[%d] ref_count:%d. excute media_format_unref().\n", i, ref_count);
 
                        if (ref_count == 1) {