This is an automated email from the ASF dual-hosted git repository. pkarashchenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 1212d3b7d89a15aaf831021419ce3404b76a2efd Author: SPRESENSE <[email protected]> AuthorDate: Thu Feb 3 10:12:26 2022 +0900 drivers/video: Fix multiplication overflow Add cast to uint32_t type to avoid multiplication overflow. --- drivers/video/video.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/video/video.c b/drivers/video/video.c index f4a3dfbfd4..ac3fd47687 100644 --- a/drivers/video/video.c +++ b/drivers/video/video.c @@ -626,11 +626,13 @@ static void get_clipped_format(uint8_t nr_fmt, &fmt[VIDEO_FMT_SUB], sizeof(video_format_t)); - c_fmt[VIDEO_FMT_SUB].width *= clip->width; - c_fmt[VIDEO_FMT_SUB].width /= fmt[VIDEO_FMT_MAIN].width; + c_fmt[VIDEO_FMT_SUB].width + = (uint32_t)c_fmt[VIDEO_FMT_SUB].width + * clip->width / fmt[VIDEO_FMT_MAIN].width; - c_fmt[VIDEO_FMT_SUB].height *= clip->height; - c_fmt[VIDEO_FMT_SUB].height /= fmt[VIDEO_FMT_MAIN].height; + c_fmt[VIDEO_FMT_SUB].height + = (uint32_t)c_fmt[VIDEO_FMT_SUB].height + * clip->height / fmt[VIDEO_FMT_MAIN].height; } } else
