[gs-cvs] rev 7889 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Tue May 1 13:52:58 PDT 2007
Author: leonardo
Date: 2007-05-01 13:52:58 -0700 (Tue, 01 May 2007)
New Revision: 7889
Modified:
trunk/gs/src/gxshade6.c
Log:
Fix (shadings) : wedge_vertex_list_elem_buffer overflow.
DETAILS :
Bug 689189 "PDF fails with /unregistered in --shfill--".
The estimation for wedge_vertex_list_elem_count_max
assumed a division of 1 side per level.
However triangle_by_4 divides 3 sides at once.
Now we increase the buffer size according to that,
see comment in code for details.
It increases the buffer size from 110K to 220K.
We tried to implement a new function triangle_by_2
to keep the old buffer size,
triangle_by_2 must be the topmost worker for fill_triangle.
This function appears almost same as triangle_by_4,
except it divides the biggest side only.
We discontinued this effort because
we don't like the code duplication,
which only saves 100K of RAM,
and gives lots of minor raster differences.
This patch fixes the failure,
but the performance with the test case appears unsatisfactory.
It sould be a subject of a separate patch.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gxshade6.c
===================================================================
--- trunk/gs/src/gxshade6.c 2007-04-30 19:08:16 UTC (rev 7888)
+++ trunk/gs/src/gxshade6.c 2007-05-01 20:52:58 UTC (rev 7889)
@@ -601,7 +601,17 @@
const int max_level = LAZY_WEDGES_MAX_LEVEL;
gs_memory_t *memory = pfs->pis->memory;
- pfs->wedge_vertex_list_elem_count_max = max_level * (1 << max_level);
+ /* We have 'max_level' levels, each of which divides 1 or 3 sides.
+ LAZY_WEDGES stores all 2^level divisions until
+ the other area of same bnoundary is processed.
+ Thus the upper estimation of the buffer size is :
+ max_level * (1 << max_level) * 3.
+ Likely this estimation to be decreased to
+ max_level * (1 << max_level) * 2.
+ because 1 side of a triangle is always outside the division path.
+ For now we set the smaller estimation for obtaining an experimental data
+ from the wild. */
+ pfs->wedge_vertex_list_elem_count_max = max_level * (1 << max_level) * 2;
pfs->wedge_vertex_list_elem_buffer = (wedge_vertex_list_elem_t *)gs_alloc_bytes(memory,
sizeof(wedge_vertex_list_elem_t) * pfs->wedge_vertex_list_elem_count_max,
"alloc_wedge_vertex_list_elem_buffer");
More information about the gs-cvs
mailing list