utils.h: add SizeOverflow()

this normalizes the 'size != (size_t)size' checks in the libraries.

Change-Id: I1e8ccd0d3697266f23911ecf0f7a546f011befde
This commit is contained in:
James Zern
2021-06-14 12:20:35 -07:00
parent 695bdaa2f6
commit 28d488e6f1
6 changed files with 13 additions and 9 deletions

View File

@ -312,7 +312,7 @@ static int InitYUVRescaler(const VP8Io* const io, WebPDecParams* const p) {
}
rescaler_size = num_rescalers * sizeof(*p->scaler_y) + WEBP_ALIGN_CST;
total_size += rescaler_size;
if (total_size != (size_t)total_size) {
if (!CheckSizeOverflow(total_size)) {
return 0;
}
@ -499,7 +499,7 @@ static int InitRGBRescaler(const VP8Io* const io, WebPDecParams* const p) {
total_size = tmp_size1 * sizeof(*work) + tmp_size2 * sizeof(*tmp);
rescaler_size = num_rescalers * sizeof(*p->scaler_y) + WEBP_ALIGN_CST;
total_size += rescaler_size;
if (total_size != (size_t)total_size) {
if (!CheckSizeOverflow(total_size)) {
return 0;
}