Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Unified Diff: third_party/libwebp/dec/buffer.c

Issue 10690171: libwebp: fix some int <-> size_t mix for buffer sizes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: even newer patch Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libwebp/README.chromium ('k') | third_party/libwebp/webp/decode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libwebp/dec/buffer.c
diff --git a/third_party/libwebp/dec/buffer.c b/third_party/libwebp/dec/buffer.c
index a190f1fd3e2beca982498f2b9a8a73b7171112f7..caaf2f00081753cebc83fe31839ee0b71dc13d03 100644
--- a/third_party/libwebp/dec/buffer.c
+++ b/third_party/libwebp/dec/buffer.c
@@ -30,11 +30,11 @@ static VP8StatusCode CheckDecBuffer(const WebPDecBuffer* const buffer) {
const int height = buffer->height;
if (mode >= MODE_YUV) { // YUV checks
const WebPYUVABuffer* const buf = &buffer->u.YUVA;
- const int size = buf->y_stride * height;
- const int u_size = buf->u_stride * ((height + 1) / 2);
- const int v_size = buf->v_stride * ((height + 1) / 2);
- const int a_size = buf->a_stride * height;
- ok &= (size <= buf->y_size);
+ const uint64_t y_size = (uint64_t)buf->y_stride * height;
+ const uint64_t u_size = (uint64_t)buf->u_stride * ((height + 1) / 2);
+ const uint64_t v_size = (uint64_t)buf->v_stride * ((height + 1) / 2);
+ const uint64_t a_size = (uint64_t)buf->a_stride * height;
+ ok &= (y_size <= buf->y_size);
ok &= (u_size <= buf->u_size);
ok &= (v_size <= buf->v_size);
ok &= (a_size <= buf->a_size);
@@ -46,7 +46,8 @@ static VP8StatusCode CheckDecBuffer(const WebPDecBuffer* const buffer) {
}
} else { // RGB checks
const WebPRGBABuffer* const buf = &buffer->u.RGBA;
- ok &= (buf->stride * height <= buf->size);
+ const uint64_t size = (uint64_t)buf->stride * height;
+ ok &= (size <= buf->size);
ok &= (buf->stride >= width * kModeBpp[mode]);
}
return ok ? VP8_STATUS_OK : VP8_STATUS_INVALID_PARAM;
@@ -95,23 +96,23 @@ static VP8StatusCode AllocateBuffer(WebPDecBuffer* const buffer) {
WebPYUVABuffer* const buf = &buffer->u.YUVA;
buf->y = output;
buf->y_stride = stride;
- buf->y_size = (int)size;
+ buf->y_size = (size_t)size;
buf->u = output + size;
buf->u_stride = uv_stride;
- buf->u_size = (int)uv_size;
+ buf->u_size = (size_t)uv_size;
buf->v = output + size + uv_size;
buf->v_stride = uv_stride;
- buf->v_size = (int)uv_size;
+ buf->v_size = (size_t)uv_size;
if (mode == MODE_YUVA) {
buf->a = output + size + 2 * uv_size;
}
- buf->a_size = (int)a_size;
+ buf->a_size = (size_t)a_size;
buf->a_stride = a_stride;
} else { // RGBA initialization
WebPRGBABuffer* const buf = &buffer->u.RGBA;
buf->rgba = output;
buf->stride = stride;
- buf->size = (int)size;
+ buf->size = (size_t)size;
}
}
return CheckDecBuffer(buffer);
« no previous file with comments | « third_party/libwebp/README.chromium ('k') | third_party/libwebp/webp/decode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698