mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-07-30 16:26:19 +08:00
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:
parent
d23308a2a7
commit
078d7f6ffc
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user