* be found in the AUTHORS file in the root of the source tree.
*/
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
unsigned int w, unsigned int h) {
- unsigned char *data;
-
- if (x + w <= img->w && y + h <= img->h) {
+ if (x <= UINT_MAX - w && x + w <= img->w && y <= UINT_MAX - h &&
+ y + h <= img->h) {
img->d_w = w;
img->d_h = h;
} else {
const int bytes_per_sample =
(img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 2 : 1;
- data = img->img_data;
+ unsigned char *data = img->img_data;
if (img->fmt & VPX_IMG_FMT_HAS_ALPHA) {
img->planes[VPX_PLANE_ALPHA] =