From: Ivailo Monev Date: Mon, 22 Aug 2016 14:03:40 +0000 (+0000) Subject: allocating the rasterizer pool out of gray_raster_reset() is safer X-Git-Tag: 4.12.0~6808 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f184f58bc625b34549c2e83958bd5928d7d9f878;p=kde%2FKatie.git allocating the rasterizer pool out of gray_raster_reset() is safer Signed-off-by: Ivailo Monev --- diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c index 734c7a978..7e4eb91c0 100644 --- a/src/gui/painting/qgrayraster.c +++ b/src/gui/painting/qgrayraster.c @@ -1000,7 +1000,7 @@ QT_FT_Vector* point; QT_FT_Vector* limit; - char* tags; + char* tags; int n; /* index of contour in outline */ int first; /* index of first point in contour */ @@ -1345,6 +1345,45 @@ } + /**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/ + /**** a static object. *****/ + + static int + gray_raster_new( QT_FT_Raster* araster ) + { + *araster = malloc(sizeof(TRaster)); + if (!*araster) { + *araster = 0; + return ErrRaster_Memory_Overflow; + } + qt_ft_memset(*araster, 0, sizeof(TRaster)); + + return 0; + } + + + static void + gray_raster_reset( QT_FT_Raster raster, char* pool_base ) + { + PRaster rast = (PRaster)raster; + if ( raster && pool_base ) + { + rast->worker = (PWorker)pool_base; + rast->buffer = pool_base + + ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) & + ~( sizeof ( TCell ) - 1 ) ); + rast->buffer_size = ( ( pool_base + RASTER_POOL_SIZE ) - + rast->buffer ) & ~( sizeof ( TCell ) - 1 ); + rast->band_size = rast->buffer_size / ( sizeof ( TCell ) * 8 ); + } + else + { + rast->buffer = NULL; + rast->buffer_size = 0; + rast->worker = NULL; + } + } + static int gray_raster_render( QT_FT_Raster raster, const QT_FT_Raster_Params* params ) @@ -1396,45 +1435,6 @@ return gray_convert_glyph( worker ); } - - /**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/ - /**** a static object. *****/ - - static int - gray_raster_new( QT_FT_Raster* araster ) - { - *araster = malloc(sizeof(TRaster)); - if (!*araster) { - *araster = 0; - return ErrRaster_Memory_Overflow; - } - qt_ft_memset(*araster, 0, sizeof(TRaster)); - - return 0; - } - - - static void - gray_raster_reset( QT_FT_Raster raster ) - { - PRaster rast = (PRaster)raster; - - if ( raster ) - { - char pool_base[RASTER_POOL_SIZE]; - PWorker worker = (PWorker)pool_base; - - - rast->worker = worker; - rast->buffer = pool_base + - ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) & - ~( sizeof ( TCell ) - 1 ) ); - rast->buffer_size = ( ( pool_base + RASTER_POOL_SIZE ) - - rast->buffer ) & ~( sizeof ( TCell ) - 1 ); - rast->band_size = rast->buffer_size / ( sizeof ( TCell ) * 8 ); - } - } - const QT_FT_Raster_Funcs qt_ft_grays_raster = { (QT_FT_Raster_New_Func) gray_raster_new, diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 1248c3490..4d1a26bc9 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3256,7 +3256,8 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, return; } - qt_ft_grays_raster.raster_reset(*grayRaster); + char pool_base[RASTER_POOL_SIZE]; + qt_ft_grays_raster.raster_reset(*grayRaster, pool_base); QT_FT_BBox clip_box = { deviceRect.x(), deviceRect.y(), diff --git a/src/gui/painting/qrasterdefs_p.h b/src/gui/painting/qrasterdefs_p.h index 341fe809d..a89a750fd 100644 --- a/src/gui/painting/qrasterdefs_p.h +++ b/src/gui/painting/qrasterdefs_p.h @@ -458,6 +458,7 @@ QT_FT_BEGIN_HEADER /* */ /* raster :: A handle to the new raster object. */ /* */ + /* pool_base :: The address in memory of the render pool. */ /* */ /* */ /* Rasters can ignore the render pool and rely on dynamic memory */ @@ -466,7 +467,7 @@ QT_FT_BEGIN_HEADER /* recommended for efficiency purposes. */ /* */ typedef void - (*QT_FT_Raster_ResetFunc)( QT_FT_Raster raster); + (*QT_FT_Raster_ResetFunc)( QT_FT_Raster raster, char* pool); #define QT_FT_Raster_Reset_Func QT_FT_Raster_ResetFunc