From: Seungbae Shin Date: Fri, 29 Apr 2022 05:40:47 +0000 (+0900) Subject: Fix Svace/Coverity defects X-Git-Tag: submit/tizen/20220429.103739^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F90%2F274490%2F7;p=platform%2Fcore%2Fapi%2Fmediatool.git Fix Svace/Coverity defects - SIGNED_TO_BIGGER_UNSIGNED - NO_CAST.INTEGER_OVERFLOW - CHECKED_RETURN [Version] 0.1.52 [Issue Type] Svace/Coverity Change-Id: Ie13f93f372af0c74a2186cb1a0c2a6bf10043623 --- diff --git a/packaging/capi-media-tool.spec b/packaging/capi-media-tool.spec index 95f8026..06f3c6c 100644 --- a/packaging/capi-media-tool.spec +++ b/packaging/capi-media-tool.spec @@ -1,6 +1,6 @@ Name: capi-media-tool Summary: A Core API media tool library in Tizen Native API -Version: 0.1.51 +Version: 0.1.52 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_packet.c b/src/media_packet.c index 40c91a2..7e2be69 100644 --- a/src/media_packet.c +++ b/src/media_packet.c @@ -518,13 +518,13 @@ static int __pkt_dealloc_buffer(media_packet_s *handle) static size_t __pkt_calculate_video_buffer_size(media_packet_s *pkt) { int stride = 0; - int width = 0; - int height = 0; + unsigned int width = 0; + unsigned int height = 0; size_t buffersize = 0; if (MEDIA_FORMAT_IS_VIDEO(pkt->format)) { - width = pkt->format->detail.video.width; - height = pkt->format->detail.video.height; + width = (unsigned int)pkt->format->detail.video.width; + height = (unsigned int)pkt->format->detail.video.height; } /* TODO : need to check type mapping again with mm_transform */ @@ -533,7 +533,7 @@ static size_t __pkt_calculate_video_buffer_size(media_packet_s *pkt) case MEDIA_FORMAT_I420: case MEDIA_FORMAT_YV12: stride = _ROUND_UP_16(width); - buffersize = (stride + (_ROUND_UP_16(width) / 2)) * height; + buffersize = (size_t)((stride + (_ROUND_UP_16(width) / 2)) * height); break; case MEDIA_FORMAT_YUYV: case MEDIA_FORMAT_UYVY: @@ -541,17 +541,17 @@ static size_t __pkt_calculate_video_buffer_size(media_packet_s *pkt) case MEDIA_FORMAT_RGB565: case MEDIA_FORMAT_422P: stride = _ROUND_UP_16(width * 2); - buffersize = stride * height; + buffersize = (size_t)(stride * height); break; case MEDIA_FORMAT_RGB888: stride = _ROUND_UP_16(width * 3); - buffersize = stride * height; + buffersize = (size_t)(stride * height); break; case MEDIA_FORMAT_ARGB: case MEDIA_FORMAT_RGBA: case MEDIA_FORMAT_BGRA: stride = width * 4; - buffersize = stride * height; + buffersize = (size_t)(stride * height); break; case MEDIA_FORMAT_NV12: case MEDIA_FORMAT_NV12T: @@ -574,7 +574,7 @@ static size_t __pkt_calculate_video_buffer_size(media_packet_s *pkt) case MEDIA_FORMAT_XVID: case MEDIA_FORMAT_AV1: stride = _ROUND_UP_16(width); - buffersize = (stride + (_ROUND_UP_16(width) / 2)) * height; + buffersize = (size_t)((stride + (_ROUND_UP_16(width) / 2)) * height); break; default: LOGE("Not supported format"); //LCOV_EXCL_LINE diff --git a/test/media_packet_test.c b/test/media_packet_test.c index f3b8031..cfca7de 100644 --- a/test/media_packet_test.c +++ b/test/media_packet_test.c @@ -1336,11 +1336,20 @@ void display_sub_basic() gboolean input(GIOChannel *channel) { + GIOStatus status; gchar buf[MAX_STRING_LEN]; gsize read; GError *error = NULL; - g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error); + status = g_io_channel_read_chars(channel, buf, sizeof(buf), &read, &error); + if (status != G_IO_STATUS_NORMAL) { + g_printerr("failed to g_io_channel_read_chars(), status[%d][%s]", + status, error ? error->message : "(null)"); + if (error) + g_error_free(error); + return TRUE; + } + buf[read] = '\0'; g_strstrip(buf); interpret(buf);