gralloc: Add padding byte for YUV 420
YUV 420 buffers have the chroma starting at consecutive bytes but end at the same byte. This results in the second chroma size being one byte shorter in size. This isn't a problem for hardware, however, the gralloc lock_ycbcr API expects to read the same number of bytes based on the cstride for both chroma components. This could lead to it accessing memory beyond what is allocated leading to a crash in the calling process especially when the size aligns exactly to the page size. Add one byte padding when allocating YUV buffers to make sure the users of this gralloc API get enough bytes to read. Bug: 10787131 Change-Id: Id18e0739f9fdc2c7a4fbe7724be668a989f1a4a1 (cherry picked from commit ca07ffae967e7137fb0d97fb9999a11c09b4a7b5)
This commit is contained in:
committed by
Arun Kumar K.R
parent
ff511027c4
commit
2c215298e1
@@ -315,7 +315,7 @@ size_t getBufferSizeAndDimensions(int width, int height, int format,
|
||||
case HAL_PIXEL_FORMAT_YCbCr_420_SP:
|
||||
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
||||
alignedh = height;
|
||||
size = ALIGN((alignedw*alignedh) + (alignedw* alignedh)/2, 4096);
|
||||
size = ALIGN((alignedw*alignedh) + (alignedw* alignedh)/2 + 1, 4096);
|
||||
break;
|
||||
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
|
||||
case HAL_PIXEL_FORMAT_YCrCb_422_SP:
|
||||
|
||||
Reference in New Issue
Block a user