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,17 +26,15 @@ static void inline cRasterPixels(PIXEL_T* dst, PIXEL_T val, uint32_t offset, int
|
||||||
dst += offset;
|
dst += offset;
|
||||||
|
|
||||||
//fix the misaligned memory
|
//fix the misaligned memory
|
||||||
auto alignOffset = 0;
|
auto alignOffset = (long) dst % 8;
|
||||||
if (sizeof(PIXEL_T) == 4) alignOffset = offset % 2;
|
if (alignOffset > 0) {
|
||||||
else if (sizeof(PIXEL_T) == 1) {
|
if (sizeof(PIXEL_T) == 4) alignOffset /= 4;
|
||||||
alignOffset = offset % 8;
|
else if (sizeof(PIXEL_T) == 1) alignOffset = 8 - alignOffset;
|
||||||
if (alignOffset > 0) alignOffset = 8 - alignOffset;
|
while (alignOffset > 0 && len > 0) {
|
||||||
}
|
*dst++ = val;
|
||||||
|
--len;
|
||||||
while (alignOffset > 0 && len > 0) {
|
--alignOffset;
|
||||||
*dst++ = val;
|
}
|
||||||
--len;
|
|
||||||
--alignOffset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//64bits faster clear
|
//64bits faster clear
|
||||||
|
|
Loading…
Add table
Reference in a new issue