[0.3.116] fix coverity issue 15/206015/2 submit/tizen/20190513.085714
authorEunhye Choi <eunhae1.choi@samsung.com>
Mon, 13 May 2019 08:20:38 +0000 (17:20 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Mon, 13 May 2019 08:22:18 +0000 (17:22 +0900)
Change-Id: I0222f759a4bf0e4c4dde907cf9166e801b1725da

packaging/capi-media-player.spec
src/player.c

index d57fd01..81c1d9c 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-player
 Summary:    A Media Player API
-Version:    0.3.115
+Version:    0.3.116
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 44e328f..4e37866 100644 (file)
@@ -4139,6 +4139,7 @@ int player_push_media_stream(player_h player, media_packet_h packet)
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(packet);
        int ret = PLAYER_ERROR_NONE;
+       int packet_ret = MEDIA_PACKET_ERROR_NONE;
        player_cli_s *pc = (player_cli_s *)player;
        muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
        char *ret_buf = NULL;
@@ -4162,29 +4163,50 @@ int player_push_media_stream(player_h player, media_packet_h packet)
 
        LOGD("ENTER");
 
-       media_packet_get_buffer_data_ptr(packet, (void **)&buf);
-       media_packet_get_buffer_size(packet, &push_media.size);
-       media_packet_get_pts(packet, &push_media.pts);
-       media_packet_get_format(packet, &format);
-       media_packet_get_flags(packet, &push_media.flags);
-       if (media_packet_get_codec_data(packet, (void **)&codec_data, &codec_data_size) == MEDIA_PACKET_ERROR_NONE) {
-               if (codec_data_size > 0 && codec_data_size <= sizeof(push_media.codec_data))
-                       memcpy(push_media.codec_data, codec_data, codec_data_size);
+       if(media_packet_get_buffer_data_ptr(packet, (void **)&buf) != MEDIA_PACKET_ERROR_NONE) {
+               LOGE("failed to get buffer data ptr");
+               return PLAYER_ERROR_INVALID_OPERATION;
        }
 
-       push_media.codec_data_size = codec_data_size;
-       push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
+       if(media_packet_get_buffer_size(packet, &push_media.size) != MEDIA_PACKET_ERROR_NONE) {
+               LOGE("failed to get buffer size");
+               return PLAYER_ERROR_INVALID_OPERATION;
+       }
+
+       if(media_packet_get_pts(packet, &push_media.pts) != MEDIA_PACKET_ERROR_NONE) {
+               LOGE("failed to get buffer pts");
+               return PLAYER_ERROR_INVALID_OPERATION;
+       }
 
-       media_packet_is_video(packet, &is_video);
-       media_packet_is_audio(packet, &is_audio);
-       media_packet_is_end_of_stream(packet, &is_eos);
+       if(media_packet_get_format(packet, &format) != MEDIA_PACKET_ERROR_NONE) {   /* format ref count is increased */
+               LOGE("failed to get media format");
+               return PLAYER_ERROR_INVALID_OPERATION;
+       }
+
+       packet_ret = media_packet_get_flags(packet, &push_media.flags);
+       packet_ret |= media_packet_is_video(packet, &is_video);
+       packet_ret |= media_packet_is_audio(packet, &is_audio);
+       packet_ret |= media_packet_is_end_of_stream(packet, &is_eos);
        if (is_video)
-               media_format_get_video_info(format, &push_media.mimetype, &push_media.width, &push_media.height, NULL, NULL);
+               packet_ret |= media_format_get_video_info(format, &push_media.mimetype, &push_media.width, &push_media.height, NULL, NULL);
        else if (is_audio)
-               media_format_get_audio_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
+               packet_ret |= media_format_get_audio_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
 
        media_format_unref(format);
 
+       if (packet_ret != MEDIA_PACKET_ERROR_NONE) {
+               LOGE("failed to get media packet info");
+               return PLAYER_ERROR_INVALID_OPERATION;
+       }
+
+       if (media_packet_get_codec_data(packet, (void **)&codec_data, &codec_data_size) == MEDIA_PACKET_ERROR_NONE) {
+               if (codec_data_size > 0 && codec_data_size <= sizeof(push_media.codec_data))
+                       memcpy(push_media.codec_data, codec_data, codec_data_size);
+       }
+
+       push_media.codec_data_size = codec_data_size;
+       push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
+
 #ifdef __UN_USED
        int arr_buf_len = 0;