FS-7500: be safe for patch and fill, off by 1

This commit is contained in:
Seven Du 2015-02-13 14:28:28 +08:00 committed by Michael Jerris
parent f18b872cde
commit 9faf03c91e
1 changed files with 4 additions and 4 deletions

View File

@ -97,11 +97,11 @@ SWITCH_DECLARE(void) switch_img_patch(switch_image_t *IMG, switch_image_t *img,
if (y & 0x1) y++;
if (len <= 0) return;
for (i = y; i < (y + img->d_h) && i < IMG->d_h; i++) {
for (i = y; i < max_h; i++) {
memcpy(IMG->planes[SWITCH_PLANE_Y] + IMG->stride[SWITCH_PLANE_Y] * i + x, img->planes[SWITCH_PLANE_Y] + img->stride[SWITCH_PLANE_Y] * (i - y), len);
}
if ((len & 1) && (x + len) < img->d_w) len++;
if ((len & 1) && (x + len) < img->d_w - 1) len++;
len /= 2;
@ -201,11 +201,11 @@ SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, i
if (y & 1) y++;
if (len <= 0) return;
for (i = y; i < (y + h) && i < img->d_h; i++) {
for (i = y; i < max_h; i++) {
memset(img->planes[SWITCH_PLANE_Y] + img->stride[SWITCH_PLANE_Y] * i + x, yuv_color.y, len);
}
if ((len & 1) && (x + len) < img->d_w) len++;
if ((len & 1) && (x + len) < img->d_w - 1) len++;
len /= 2;