[gs-cvs] rev 8440 - trunk/gs/src

alexcher at ghostscript.com alexcher at ghostscript.com
Fri Dec 14 10:31:40 PST 2007


Author: alexcher
Date: 2007-12-14 10:31:39 -0800 (Fri, 14 Dec 2007)
New Revision: 8440

Modified:
   trunk/gs/src/gxclist.c
Log:
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


Modified: trunk/gs/src/gxclist.c
===================================================================
--- trunk/gs/src/gxclist.c	2007-12-12 20:29:44 UTC (rev 8439)
+++ trunk/gs/src/gxclist.c	2007-12-14 18:31:39 UTC (rev 8440)
@@ -309,17 +309,21 @@
     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;
 }
 



More information about the gs-cvs mailing list