summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiarhei Siamashka <siarhei.siamashka@nokia.com>2010-11-30 00:31:06 +0200
committerSøren Sandmann Pedersen <ssp@redhat.com>2011-01-19 08:10:11 -0500
commite7aa109ca937d50421cc7b41dfc142becc53404a (patch)
tree28c7910e6cb2ad505effaa02589fa3129e5d164c
parent724f5e67b35420119222a4692d1fe9f4c8f49ba2 (diff)
downloadpixman-e7aa109ca937d50421cc7b41dfc142becc53404a.tar.gz
Fix for potential unaligned memory accesses
The temporary scanline buffer allocated on stack was declared as uint8_t array. As a result, the compiler was free to select any arbitrary alignment for it (even though there is typically no reason to use really weird alignments here and the stack is normally at least 4 bytes aligned on most platforms). Having improper alignment is non-portable and can impact performance or even make the code misbehave depending on the target platform. Using uint64_t type for this array should ensure that any possible memory accesses done by pixman code are going to be handled correctly (pixman-combine64.c can access this buffer via uint64_t * pointer). Some alignment related problem was reported in: http://lists.freedesktop.org/archives/pixman/2010-November/000747.html
-rw-r--r--pixman/pixman-general.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 4d234a0..8130f16 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -56,8 +56,8 @@ general_composite_rect (pixman_implementation_t *imp,
int32_t width,
int32_t height)
{
- uint8_t stack_scanline_buffer[SCANLINE_BUFFER_LENGTH * 3];
- uint8_t *scanline_buffer = stack_scanline_buffer;
+ uint64_t stack_scanline_buffer[(SCANLINE_BUFFER_LENGTH * 3 + 7) / 8];
+ uint8_t *scanline_buffer = (uint8_t *) stack_scanline_buffer;
uint8_t *src_buffer, *mask_buffer, *dest_buffer;
fetch_scanline_t fetch_src = NULL, fetch_mask = NULL, fetch_dest = NULL;
pixman_combine_32_func_t compose;
@@ -255,7 +255,7 @@ general_composite_rect (pixman_implementation_t *imp,
}
}
- if (scanline_buffer != stack_scanline_buffer)
+ if (scanline_buffer != (uint8_t *) stack_scanline_buffer)
free (scanline_buffer);
}