From: Po Lu Date: Mon, 29 May 2023 08:33:20 +0000 (+0800) Subject: Update Android port X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9a3535459333b5a1a32ed5b5ef4c593e585bfe9a;p=emacs.git Update Android port * src/android.c (android_neon_mask_line): Fix iteration over remainder. (android_blit_copy): Be more paranoid. --- diff --git a/src/android.c b/src/android.c index 33d766a90d9..7b9c478f212 100644 --- a/src/android.c +++ b/src/android.c @@ -3958,14 +3958,14 @@ android_neon_mask_line (unsigned int *src, unsigned int *dst, uint32x4_t src_low, src_high, dst_low, dst_high; int16x8_t vmask; int32x4_t ext_mask_low, ext_mask_high, low, high; - int rem; + int rem, i; /* Calculate the remainder. */ - rem = n & 7; + rem = n & 7, n &= ~7; /* Process eight pixels at a time. */ - if (n -= rem) + if (n) { again: /* Load the low and high four pixels from the source. */ @@ -4008,14 +4008,13 @@ android_neon_mask_line (unsigned int *src, unsigned int *dst, /* Process the remaining pixels. */ - while (--rem) + for (i = 0; i < rem; ++i) { /* Sign extend the mask. */ - n = *(signed char *) mask++; + n = ((signed char *) mask)[i]; /* Combine src and dst. */ - *dst = ((*src & n) | (*dst & ~n)); - src++, dst++; + dst[i] = ((src[i] & n) | (dst[i] & ~n)); } } @@ -4262,7 +4261,8 @@ android_blit_copy (int src_x, int src_y, int width, int height, /* Make sure it's not out of bounds. */ eassert (dst_y - gc->clip_y_origin >= 0); - if ((dst_y - gc->clip_y_origin) + height > mask_info->height) + if ((dst_y - gc->clip_y_origin) + height > mask_info->height + || width <= 0) return; /* Now move mask to the position of the first row. */ @@ -4277,6 +4277,9 @@ android_blit_copy (int src_x, int src_y, int width, int height, else temp = MIN (mask_info->width, width); + if (temp <= 0) + return; + /* Copy bytes according to the mask. */ while (--height)