aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Fedchin <afedchin@ruswizards.com>2016-01-05 15:06:10 +0300
committerAnton Fedchin <afedchin@ruswizards.com>2016-01-05 15:13:42 +0300
commit298bf0bb506cf9d91a61e6a54309a5598ae83c9b (patch)
treee681f80a068e098a72e9ab4fb3d6558d886e3593
parentefbb55d3cef24da8c73891407121493f1f1962f6 (diff)
[win32] memcpy_sse2: Fixed possible heap corruption if chroma width is not 16 aligned.
-rw-r--r--xbmc/utils/win32/memcpy_sse2.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/xbmc/utils/win32/memcpy_sse2.h b/xbmc/utils/win32/memcpy_sse2.h
index d5c5844b58..e6ea34a940 100644
--- a/xbmc/utils/win32/memcpy_sse2.h
+++ b/xbmc/utils/win32/memcpy_sse2.h
@@ -108,7 +108,17 @@ inline void convert_yuv420_nv12(uint8_t *const src[], const int srcStride[], int
_mm_stream_si128((__m128i *)(d + (i << 1) + 32), xmm2);
_mm_stream_si128((__m128i *)(d + (i << 1) + 48), xmm1);
}
- for (; i < chromaWidth; i += 16)
+ if (((size_t)chromaWidth) & 0xF)
+ {
+ d += (i << 1);
+ u += i; v += i;
+ for (; i < chromaWidth; ++i)
+ {
+ *d++ = *u++;
+ *d++ = *v++;
+ }
+ }
+ else
{
xmm0 = _mm_load_si128((__m128i*)(v + i));
xmm1 = _mm_load_si128((__m128i*)(u + i));