mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-03-07 04:00:31 +01:00
[cairo-path-fixed] Ensure the array of points is correctly aligned.
In http://bugs.gentoo.org/show_bug.cgi?id=203282, it was identified that the cairo_path_buf was causing unaligned accesses (thus generating SIGBUS on architectures like the SPARC) to its array of points. As we manually allocate a single block of memory for the cairo_path_buf_t and its arrays, we must also manually ensure correct alignment - as opposed to cairo_path_buf_fixed_t for which the compiler automatically aligns the embedded arrays.
This commit is contained in:
parent
7f69c2588b
commit
d8169b8cef
1 changed files with 6 additions and 3 deletions
|
|
@ -404,10 +404,12 @@ _cairo_path_buf_create (int buf_size)
|
|||
{
|
||||
cairo_path_buf_t *buf;
|
||||
|
||||
#define align(ptr__, alignment__) \
|
||||
((void *) (((long) (ptr__) + (alignment__) - 1) & -(alignment__)))
|
||||
buf = _cairo_malloc_ab_plus_c (buf_size,
|
||||
sizeof (cairo_path_op_t) +
|
||||
2 * sizeof (cairo_point_t),
|
||||
sizeof (cairo_path_buf_t));
|
||||
sizeof (cairo_path_buf_t) + sizeof (double));
|
||||
if (buf) {
|
||||
buf->next = NULL;
|
||||
buf->prev = NULL;
|
||||
|
|
@ -415,9 +417,10 @@ _cairo_path_buf_create (int buf_size)
|
|||
buf->num_points = 0;
|
||||
buf->buf_size = buf_size;
|
||||
|
||||
buf->op = (cairo_path_op_t *) (buf + 1);
|
||||
buf->points = (cairo_point_t *) (buf->op + buf_size);
|
||||
buf->points = (cairo_point_t *) align (buf + 1, sizeof (double));
|
||||
buf->op = (cairo_path_op_t *) (buf->points + 2 * buf_size);
|
||||
}
|
||||
#undef align
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue