From c311a1c695e8b2c5bb5190c26d13752fd35982ae Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 2 Jun 2021 10:47:10 +0200 Subject: [PATCH] Fixed issues with planar codec buffer alignment Align width and height to next multiple of 4 to avoid issues with internal buffer sizes. (cherry picked from commit c2049673be9be05a87d62759c55893759ed64d05) --- libfreerdp/codec/planar.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libfreerdp/codec/planar.c b/libfreerdp/codec/planar.c index 8588a9e..12b9f6d 100644 --- a/libfreerdp/codec/planar.c +++ b/libfreerdp/codec/planar.c @@ -33,6 +33,8 @@ #define TAG FREERDP_TAG("codec") +#define ALIGN(val, align) ((val) % (align) == 0) ? (val) : ((val) + (align) - (val) % (align)) + static INLINE UINT32 planar_invert_format(BITMAP_PLANAR_CONTEXT* planar, BOOL alpha, UINT32 DstFormat) { @@ -1482,8 +1484,8 @@ BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context, UINT32 return FALSE; context->bgr = FALSE; - context->maxWidth = width; - context->maxHeight = height; + context->maxWidth = ALIGN(width, 4); + context->maxHeight = ALIGN(height, 4); context->maxPlaneSize = context->maxWidth * context->maxHeight; context->nTempStep = context->maxWidth * 4; free(context->planesBuffer); -- 2.7.4