OSDN Git Service

allocating the rasterizer pool out of gray_raster_reset() is safer
authorIvailo Monev <xakepa10@laimg.moc>
Mon, 22 Aug 2016 14:03:40 +0000 (14:03 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Mon, 22 Aug 2016 14:03:40 +0000 (14:03 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/painting/qgrayraster.c
src/gui/painting/qpaintengine_raster.cpp
src/gui/painting/qrasterdefs_p.h

index 734c7a9..7e4eb91 100644 (file)
 
     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 */
   }
 
 
+  /**** 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 )
     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,
index 1248c34..4d1a26b 100644 (file)
@@ -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(),
index 341fe80..a89a750 100644 (file)
@@ -458,6 +458,7 @@ QT_FT_BEGIN_HEADER
   /* <Input>                                                               */
   /*    raster    :: A handle to the new raster object.                    */
   /*                                                                       */
+  /*    pool_base :: The address in memory of the render pool.             */
   /*                                                                       */
   /* <Note>                                                                */
   /*    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