freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master bfbd782: [graph] Initialize local variables aft


From: Werner LEMBERG
Subject: [freetype2-demos] master bfbd782: [graph] Initialize local variables after checking channel change.
Date: Mon, 30 Nov 2015 06:54:17 +0000

branch: master
commit bfbd78261beff2d63f32212ba6ebae66b6db99f4
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [graph] Initialize local variables after checking channel change.
    
    This fixes a crash if foreground color == background color.
    
    Problem reported by Alexei.
    
    * graph/gblender.h (GBLENDER_VARS): Split off initialization to...
    (GBLENDER_VARS_SET): ...this new macro.
    (GBLENDER_CHANNEL_VARS): Split off initialization to...
    (GBLENDER_CHANNEL_VARS_SET): ...this new macro.
    
    * graph/gblcolor.h, graph/gblhbgr.h, graph/gblhrgb.h,
    graph/gblvbgr.h, graph/gblvrgb.h: Updated.
---
 ChangeLog        |   16 ++++++++++++++++
 graph/gblcolor.h |    4 +++-
 graph/gblender.h |   44 ++++++++++++++++++++++++++++++--------------
 graph/gblhbgr.h  |    5 ++++-
 graph/gblhrgb.h  |    4 +++-
 graph/gblvbgr.h  |    4 +++-
 graph/gblvrgb.h  |    4 +++-
 7 files changed, 62 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6cb23e7..3c85bf8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2015-11-30  Werner Lemberg  <address@hidden>
+
+       [graph] Initialize local variables after checking channel change.
+
+       This fixes a crash if foreground color == background color.
+
+       Problem reported by Alexei.
+
+       * graph/gblender.h (GBLENDER_VARS): Split off initialization to...
+       (GBLENDER_VARS_SET): ...this new macro.
+       (GBLENDER_CHANNEL_VARS): Split off initialization to...
+       (GBLENDER_CHANNEL_VARS_SET): ...this new macro.
+
+       * graph/gblcolor.h, graph/gblhbgr.h, graph/gblhrgb.h,
+       graph/gblvbgr.h, graph/gblvrgb.h: Updated.
+
 2015-11-29  Alexei Podtelezhnikov  <address@hidden>
 
        * graph/gblender.c (gblender_clear): Fix typo.
diff --git a/graph/gblcolor.h b/graph/gblcolor.h
index 53381ba..a72dee4 100644
--- a/graph/gblcolor.h
+++ b/graph/gblcolor.h
@@ -1,5 +1,5 @@
 
-  GBLENDER_VARS(blender,color);
+  GBLENDER_VARS;
 
   int                   h        = blit->height;
   const unsigned char*  src_line = blit->src_line;
@@ -7,6 +7,8 @@
 
   gblender_use_channels( blender, 0 );
 
+  GBLENDER_VARS_SET(blender,color);
+
   /* make compiler happy */
   (void)(r);
   (void)(g);
diff --git a/graph/gblender.h b/graph/gblender.h
index ab9771c..d1b092a 100644
--- a/graph/gblender.h
+++ b/graph/gblender.h
@@ -148,10 +148,15 @@
 
 
   /* no final `;'! */
-#define  GBLENDER_VARS(_gb,_fore)                                              
                                                 \
-   GBlenderPixel    _gback  = (_gb)->cache_back;                               
                                                 \
-   GBlenderCell*    _gcells = ( (_fore) == (_gb)->cache_fore ? 
(_gb)->cache_cells : gblender_lookup( (_gb), _gback, _fore ) );  \
-   GBlenderPixel    _gfore  = (_fore)
+#define  GBLENDER_VARS    \
+  GBlenderPixel  _gback;  \
+  GBlenderCell*  _gcells; \
+  GBlenderPixel  _gfore
+
+#define  GBLENDER_VARS_SET(_gb,_fore)                                          
                               \
+  _gback  = (_gb)->cache_back;                                                 
                               \
+  _gcells = ( (_fore) == (_gb)->cache_fore ? (_gb)->cache_cells : 
gblender_lookup( (_gb), _gback, _fore ) );  \
+  _gfore  = (_fore)
 
 #define  GBLENDER_LOOKUP(gb,back)                        \
    GBLENDER_STAT_HIT(gb);                                \
@@ -169,16 +174,27 @@
 
 
   /* no final `;'! */
-#define  GBLENDER_CHANNEL_VARS(_gb,_rfore,_gfore,_bfore)                       
                                                                  \
-   unsigned int     _grback  = (_gb)->cache_r_back;                            
                                                                  \
-   unsigned char*   _grcells = ( (_rfore) == (_gb)->cache_r_fore ? 
(_gb)->cache_r_cells : gblender_lookup_channel( (_gb), _grback, _rfore ));    \
-   unsigned int     _grfore  = (_rfore);                                       
                                                                  \
-   unsigned int     _ggback  = (_gb)->cache_g_back;                            
                                                                  \
-   unsigned char*   _ggcells = ( (_gfore) == (_gb)->cache_g_fore ? 
(_gb)->cache_g_cells : gblender_lookup_channel( (_gb), _ggback, _gfore ));    \
-   unsigned int     _ggfore  = (_rfore);                                       
                                                                  \
-   unsigned int     _gbback  = (_gb)->cache_b_back;                            
                                                                  \
-   unsigned char*   _gbcells = ( (_bfore) == (_gb)->cache_b_fore ? 
(_gb)->cache_b_cells : gblender_lookup_channel( (_gb), _gbback, _bfore ));    \
-   unsigned int     _gbfore  = (_bfore)
+#define  GBLENDER_CHANNEL_VARS \
+  unsigned int    _grback;     \
+  unsigned char*  _grcells;    \
+  unsigned int    _grfore;     \
+  unsigned int    _ggback;     \
+  unsigned char*  _ggcells;    \
+  unsigned int    _ggfore;     \
+  unsigned int    _gbback;     \
+  unsigned char*  _gbcells;    \
+  unsigned int    _gbfore
+
+#define  GBLENDER_CHANNEL_VARS_SET(_gb,_rfore,_gfore,_bfore)                   
                                             \
+  _grback  = (_gb)->cache_r_back;                                              
                                             \
+  _grcells = ( (_rfore) == (_gb)->cache_r_fore ? (_gb)->cache_r_cells : 
gblender_lookup_channel( (_gb), _grback, _rfore )); \
+  _grfore  = (_rfore);                                                         
                                             \
+  _ggback  = (_gb)->cache_g_back;                                              
                                             \
+  _ggcells = ( (_gfore) == (_gb)->cache_g_fore ? (_gb)->cache_g_cells : 
gblender_lookup_channel( (_gb), _ggback, _gfore )); \
+  _ggfore  = (_gfore);                                                         
                                             \
+  _gbback  = (_gb)->cache_b_back;                                              
                                             \
+  _gbcells = ( (_bfore) == (_gb)->cache_b_fore ? (_gb)->cache_b_cells : 
gblender_lookup_channel( (_gb), _gbback, _bfore )); \
+  _gbfore  = (_bfore);
 
 #define  GBLENDER_CHANNEL_CLOSE(_gb)   \
   (_gb)->cache_r_back  = _grback;      \
diff --git a/graph/gblhbgr.h b/graph/gblhbgr.h
index bc8876b..d5de10b 100644
--- a/graph/gblhbgr.h
+++ b/graph/gblhbgr.h
@@ -1,4 +1,5 @@
-  GBLENDER_CHANNEL_VARS(blender,r,g,b);
+
+  GBLENDER_CHANNEL_VARS;
 
   int                   h        = blit->height;
   const unsigned char*  src_line = blit->src_line;
@@ -6,6 +7,8 @@
 
   gblender_use_channels( blender, 1 );
 
+  GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
+
   do
   {
     const unsigned char*  src = src_line + blit->src_x*3;
diff --git a/graph/gblhrgb.h b/graph/gblhrgb.h
index ee33612..4467b2a 100644
--- a/graph/gblhrgb.h
+++ b/graph/gblhrgb.h
@@ -1,5 +1,5 @@
 
-  GBLENDER_CHANNEL_VARS(blender,r,g,b);
+  GBLENDER_CHANNEL_VARS;
 
   int                   h        = blit->height;
   const unsigned char*  src_line = blit->src_line;
@@ -7,6 +7,8 @@
 
   gblender_use_channels( blender, 1 );
 
+  GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
+
   do
   {
     const unsigned char*  src = src_line + blit->src_x*3;
diff --git a/graph/gblvbgr.h b/graph/gblvbgr.h
index 89d3a3b..67effae 100644
--- a/graph/gblvbgr.h
+++ b/graph/gblvbgr.h
@@ -1,5 +1,5 @@
 
-  GBLENDER_CHANNEL_VARS(blender,r,g,b);
+  GBLENDER_CHANNEL_VARS;
 
   int                   h         = blit->height;
   const unsigned char*  src_line  = blit->src_line;
@@ -8,6 +8,8 @@
 
   gblender_use_channels( blender, 1 );
 
+  GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
+
   do
   {
     const unsigned char*  src = src_line + blit->src_x;
diff --git a/graph/gblvrgb.h b/graph/gblvrgb.h
index 04461f0..6b9edde 100644
--- a/graph/gblvrgb.h
+++ b/graph/gblvrgb.h
@@ -1,5 +1,5 @@
 
-  GBLENDER_CHANNEL_VARS(blender,r,g,b);
+  GBLENDER_CHANNEL_VARS;
 
   int                   h         = blit->height;
   const unsigned char*  src_line  = blit->src_line;
@@ -8,6 +8,8 @@
 
   gblender_use_channels( blender, 1 );
 
+  GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
+
   do
   {
     const unsigned char*  src = src_line + blit->src_x;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]