Fix Coverity Control flow issues (DEADCODE)

Suppose the variable `size` is of the uint64_t type. The condition
size > SIZE_MAX is always false if size_t is 64 bits, so the code inside
the body of `if (size > SIZE_MAX)` is dead code.

Fix Coverity defects CID 561616, CID 561617, CID 561618.

Change-Id: I91172896711943bdcec017edce3a9d1e389d9f88
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8020303
Reviewed-by: Frank Barchard <fbarchard@google.com>
Commit-Queue: Wan-Teh Chang <wtc@google.com>
This commit is contained in:
Wan-Teh Chang 2026-06-29 09:49:27 -07:00 committed by libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com
parent d23308a2a7
commit 078d7f6ffc
3 changed files with 6 additions and 0 deletions

View File

@ -92,9 +92,11 @@ int ConvertToARGB(const uint8_t* sample,
if (need_buf) {
const uint64_t rotate_buffer_size =
(uint64_t)crop_width * 4 * abs_crop_height;
#if UINT64_MAX > SIZE_MAX
if (rotate_buffer_size > SIZE_MAX) {
return -1; // Invalid size.
}
#endif
rotate_buffer = (uint8_t*)malloc((size_t)rotate_buffer_size);
if (!rotate_buffer) {
return 1; // Out of memory runtime error.

View File

@ -844,9 +844,11 @@ int YUVToARGBScaleClip(const uint8_t* src_y,
}
const int abs_src_height = (src_height < 0) ? -src_height : src_height;
const uint64_t argb_buffer_size = (uint64_t)src_width * abs_src_height * 4;
#if UINT64_MAX > SIZE_MAX
if (argb_buffer_size > SIZE_MAX) {
return -1; // Invalid size.
}
#endif
uint8_t* argb_buffer = (uint8_t*)malloc((size_t)argb_buffer_size);
if (!argb_buffer) {
return 1; // Out of memory runtime error.

View File

@ -53,9 +53,11 @@ int RGBScale(const uint8_t* src_rgb,
return -1; // Invalid size.
}
const uint64_t argb_size = src_argb_size + dst_argb_size;
#if UINT64_MAX > SIZE_MAX
if (argb_size > SIZE_MAX) {
return -1; // Invalid size.
}
#endif
uint8_t* src_argb = (uint8_t*)malloc((size_t)argb_size);
if (!src_argb) {
return 1; // Out of memory runtime error.