[0.6.71] Fix coverity issues 64/153764/1 submit/tizen/20170929.104425
authorGilbok Lee <gilbok.lee@samsung.com>
Fri, 29 Sep 2017 01:15:41 +0000 (10:15 +0900)
committereunhae choi <eunhae1.choi@samsung.com>
Fri, 29 Sep 2017 10:26:21 +0000 (10:26 +0000)
Change-Id: Ief749be871e4cd9252a66da3c3db0709e6db5310
(cherry picked from commit 7497dc8ece5e6f75e959f94416746ddd558f681f)

packaging/libmm-player.spec
src/mm_player_attrs.c
src/mm_player_capture.c
src/mm_player_priv.c
src/mm_player_sound_focus.c
src/mm_player_tracks.c
src/mm_player_utils.c

index 176e334..5d8cfa9 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.70
+Version:    0.6.71
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 91dd447..0c0b1a2 100644 (file)
@@ -1153,7 +1153,10 @@ _mmplayer_construct_attribute(MMHandleType handle)
        }
 
        /* commit */
-       mmf_attrs_commit(attrs);
+       if (mmf_attrs_commit(attrs)) {
+               LOGE("failed to update attributes\n");
+               return 0;
+       }
 
        return attrs;
 }
index 7f8c134..46f8cca 100644 (file)
@@ -231,9 +231,6 @@ __mmplayer_handle_orientation(mm_player_t* player, int orientation, int format)
 
        /* convert orientation degree into enum here */
        switch (orientation) {
-       case 0:
-               rot_enum = MM_UTIL_ROTATE_0;
-               break;
        case 90:
                rot_enum = MM_UTIL_ROTATE_90;
                break;
@@ -858,10 +855,6 @@ __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src,
                        temp1 = left&0x3F;
                        if (temp3 > 192) {
                                memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+temp1, 64-temp1);
-                               temp2 = ((left+63)>>6)<<6;
-                               temp3 = ((yuv420_width-right)>>6)<<6;
-                               if (temp2 == temp3)
-                                       temp2 = yuv420_width-right-(64-temp1);
                                memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset+2048, 64);
                                memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1, 64);
                                memcpy(yuv420_dest+linear_offset+192-temp1, nv12t_src+tiled_offset1+2048, 64);
index bb157ad..a6680cd 100644 (file)
@@ -699,7 +699,9 @@ __mmplayer_set_state(mm_player_t* player, int state)
                                        mm_attrs_set_string_by_name(player->attrs, "content_audio_codec", audio_codec);
 
                                        MMPLAYER_FREEIF(audio_codec);
-                                       mmf_attrs_commit(player->attrs);
+                                       if (mmf_attrs_commit(player->attrs))
+                                               LOGE("failed to update attributes\n");
+
                                        LOGD("set audio codec type with caps\n");
                                }
 
@@ -1598,7 +1600,7 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data)
                                                        player->subtitle_language_list = (GList *)g_value_get_pointer(lang_list);
                                                        mm_attrs_set_int_by_name(attrs, "content_text_track_num", (gint)count);
                                                        if (mmf_attrs_commit(attrs))
-                                                         LOGE("failed to commit.\n");
+                                                               LOGE("failed to commit.\n");
                                                        LOGD("Total subtitle tracks = %d \n", count);
                                                }
                                                while (count) {
@@ -1828,20 +1830,19 @@ do {    \
 } while (0)
 
 #define MMPLAYER_UPDATE_TAG_UINT(gsttag, attribute, playertag) \
-if (gst_tag_list_get_uint(tag_list, gsttag, &v_uint)) {\
-       if (v_uint) {\
-               if (!strncmp(gsttag, GST_TAG_BITRATE, strlen(GST_TAG_BITRATE))) {\
+if (gst_tag_list_get_uint(tag_list, gsttag, &v_uint)) { \
+       if (v_uint) { \
+               if (!strncmp(gsttag, GST_TAG_BITRATE, strlen(GST_TAG_BITRATE))) { \
                        if (player->updated_bitrate_count == 0) \
                                mm_attrs_set_int_by_name(attribute, "content_audio_bitrate", v_uint); \
-                       if (player->updated_bitrate_count < MM_PLAYER_STREAM_COUNT_MAX) {\
+                       if (player->updated_bitrate_count < MM_PLAYER_STREAM_COUNT_MAX) { \
                                player->bitrate[player->updated_bitrate_count] = v_uint;\
                                player->total_bitrate += player->bitrate[player->updated_bitrate_count]; \
                                player->updated_bitrate_count++; \
                                mm_attrs_set_int_by_name(attribute, playertag, player->total_bitrate);\
                                SECURE_LOGD("update bitrate %d[bps] of stream #%d.\n", v_uint, player->updated_bitrate_count);\
                        } \
-               } \
-               else if (!strncmp(gsttag, GST_TAG_MAXIMUM_BITRATE, strlen(GST_TAG_MAXIMUM_BITRATE))) {\
+               } else if (!strncmp(gsttag, GST_TAG_MAXIMUM_BITRATE, strlen(GST_TAG_MAXIMUM_BITRATE))) {\
                        if (player->updated_maximum_bitrate_count < MM_PLAYER_STREAM_COUNT_MAX) {\
                                player->maximum_bitrate[player->updated_maximum_bitrate_count] = v_uint;\
                                player->total_maximum_bitrate += player->maximum_bitrate[player->updated_maximum_bitrate_count]; \
@@ -1849,8 +1850,9 @@ if (gst_tag_list_get_uint(tag_list, gsttag, &v_uint)) {\
                                mm_attrs_set_int_by_name(attribute, playertag, player->total_maximum_bitrate); \
                                SECURE_LOGD("update maximum bitrate %d[bps] of stream #%d\n", v_uint, player->updated_maximum_bitrate_count);\
                        } \
-               } else\
+               } else { \
                        mm_attrs_set_int_by_name(attribute, playertag, v_uint); \
+               } \
                v_uint = 0;\
        } \
 }
@@ -12118,7 +12120,8 @@ __mmplayer_eos_timer_cb(gpointer u_data)
                        player->play_count--;
 
                        mm_attrs_set_int_by_name(attrs, "profile_play_count", player->play_count);
-                       mmf_attrs_commit(attrs);
+                       if (mmf_attrs_commit(attrs))
+                               LOGE("failed to update attributes\n");
                } else {
                        LOGE("seeking to 0 failed in repeat play");
                }
@@ -12197,7 +12200,7 @@ __gst_send_event_to_sink(mm_player_t* player, GstEvent* event)
        /* Note : Textbin is not linked to the video or audio bin.
         * It needs to send the event to the text sink seperatelly.
         */
-        if (player->play_subtitle) {
+        if (player->play_subtitle && player->pipeline) {
                GstElement *text_sink = GST_ELEMENT_CAST(player->pipeline->textbin[MMPLAYER_T_FAKE_SINK].gst);
 
                if (GST_IS_ELEMENT(text_sink)) {
index 9bc37cf..0911dcf 100644 (file)
@@ -110,8 +110,6 @@ __mmplayer_sound_get_stream_type(gint type)
                LOGW("unexpected case!\n");
                return "media";
        }
-
-       return "media";
 }
 
 static bool
index ef33a96..fe3f8ee 100644 (file)
@@ -45,8 +45,8 @@ int _mmplayer_get_track_count(MMHandleType hplayer,  MMPlayerTrackType type, int
        /* check player handle */
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
-       MMPLAYER_RETURN_VAL_IF_FAIL((MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PAUSED)
-                || (MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PLAYING),
+       MMPLAYER_RETURN_VAL_IF_FAIL((MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PAUSED)
+                || (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PLAYING),
                MM_ERROR_PLAYER_INVALID_STATE);
 
        attrs = MMPLAYER_GET_ATTRS(player);
index 98c999e..eae43a3 100644 (file)
@@ -197,7 +197,7 @@ util_get_charset(const char *file_path)
        }
 
        n_size = fread(buf, 1, 1024*1024, fin);
-
+       buf[1024 * 1024 - 1] = '\0';
        if (!n_size)
                goto done;