summaryrefslogtreecommitdiff
path: root/gs
diff options
context:
space:
mode:
authorAlex Cherepanov <alex.cherepanov@artifex.com>2007-12-14 18:31:39 +0000
committerAlex Cherepanov <alex.cherepanov@artifex.com>2007-12-14 18:31:39 +0000
commiteacb9e98581131eacdee13a4941c239e733f4361 (patch)
tree4fa2d89680b12f63bb46e3eb36567954260f0b21 /gs
parentd0d4756d2e49e33907725ae2d3e69a92db7d8b05 (diff)
Align the pointer to gx_clist_state array in gx_device_clist_writer device to
the natural boundary to avoid misaligned memory access and bus errors on ARM processors. Bug 689600. DIFFERENCES: None git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@8440 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs')
-rw-r--r--gs/src/gxclist.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gs/src/gxclist.c b/gs/src/gxclist.c
index f1fd816b5..65e887650 100644
--- a/gs/src/gxclist.c
+++ b/gs/src/gxclist.c
@@ -309,17 +309,21 @@ clist_init_states(gx_device * dev, byte * init_data, uint data_size)
gx_device_clist_writer * const cdev =
&((gx_device_clist *)dev)->writer;
ulong state_size = cdev->nbands * (ulong) sizeof(gx_clist_state);
+ /* Align to the natural boundary for ARM processors, bug 689600 */
+ long alignment = (-(long)init_data) & (sizeof(init_data) - 1);
/*
* The +100 in the next line is bogus, but we don't know what the
* real check should be. We're effectively assuring that at least 100
* bytes will be available to buffer command operands.
*/
- if (state_size + sizeof(cmd_prefix) + cmd_largest_size + 100 > data_size)
+ if (state_size + sizeof(cmd_prefix) + cmd_largest_size + 100 + alignment > data_size)
return_error(gs_error_rangecheck);
+ /* The end buffer position is not affected by alignment */
+ cdev->cend = init_data + data_size;
+ init_data += alignment;
cdev->states = (gx_clist_state *) init_data;
cdev->cbuf = init_data + state_size;
- cdev->cend = init_data + data_size;
return 0;
}