mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-28 17:15:57 +00:00
sw_raster c: fix the misaligned memory access.
An issue occurred in the 64-bit accelerated raster version, involving 8 bytes of misaligned memory access. This was detected by the memory sanitizer and has now been fixed.
This commit is contained in:
parent
f551531bb5
commit
24c0b5ecf5
1 changed files with 9 additions and 11 deletions
|
@ -26,18 +26,16 @@ static void inline cRasterPixels(PIXEL_T* dst, PIXEL_T val, uint32_t offset, int
|
|||
dst += offset;
|
||||
|
||||
//fix the misaligned memory
|
||||
auto alignOffset = 0;
|
||||
if (sizeof(PIXEL_T) == 4) alignOffset = offset % 2;
|
||||
else if (sizeof(PIXEL_T) == 1) {
|
||||
alignOffset = offset % 8;
|
||||
if (alignOffset > 0) alignOffset = 8 - alignOffset;
|
||||
}
|
||||
|
||||
auto alignOffset = (long) dst % 8;
|
||||
if (alignOffset > 0) {
|
||||
if (sizeof(PIXEL_T) == 4) alignOffset /= 4;
|
||||
else if (sizeof(PIXEL_T) == 1) alignOffset = 8 - alignOffset;
|
||||
while (alignOffset > 0 && len > 0) {
|
||||
*dst++ = val;
|
||||
--len;
|
||||
--alignOffset;
|
||||
}
|
||||
}
|
||||
|
||||
//64bits faster clear
|
||||
if ((sizeof(PIXEL_T) == 4)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue