freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][ftinspect-membug] [ftinspect] Fix uniniti


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][ftinspect-membug] [ftinspect] Fix uninitialized memory issue and reference misuse. (#23)
Date: Fri, 03 Mar 2023 00:39:43 +0000

Charlie Jiang pushed to branch ftinspect-membug at FreeType / FreeType Demo Programs

Commits:

  • eebeb305
    by Charlie Jiang at 2023-03-03T08:39:23+08:00
    [ftinspect] Fix uninitialized memory issue and reference misuse. (#23)
    
    * src/ftinspect/engine/rendering.cpp:
      Properly initialize `FT_Bitmap` since it's a value type.
      Fix the accident overwriting of the source bitmap when converting the
      bitmap format (only happens for `FT_PIXEL_MODE_GRAY2` and
      `FT_PIXEL_MODE_GRAY4`) due to a misuse of C++ reference.
    
    * src/ftinspect/glyphcomponents/glyphcontinuous.cpp:
      Fix the crash when the `QImage` was failed to produce.
    

2 changed files:

Changes:

  • src/ftinspect/engine/rendering.cpp
    ... ... @@ -136,8 +136,7 @@ RenderingEngine::convertGlyphToBitmapGlyph(FT_Glyph src,
    136 136
     FT_Bitmap
    
    137 137
     RenderingEngine::convertBitmapTo8Bpp(FT_Bitmap* bitmap)
    
    138 138
     {
    
    139
    -  FT_Bitmap out;
    
    140
    -  out.buffer = NULL;
    
    139
    +  FT_Bitmap out = {};
    
    141 140
       // This will create a new bitmap object.
    
    142 141
       auto error = FT_Bitmap_Convert(engine_->ftLibrary(), bitmap, &out, 1);
    
    143 142
       if (error)
    
    ... ... @@ -167,7 +166,7 @@ RenderingEngine::convertBitmapToQImage(FT_Bitmap* src)
    167 166
     {
    
    168 167
       QImage* result = NULL;
    
    169 168
     
    
    170
    -  auto& bmap = *src;
    
    169
    +  auto bmap = *src;
    
    171 170
       bool ownBitmap = false; // If true, we need to clean up `bmap`.
    
    172 171
     
    
    173 172
       int width = INT_MAX;
    

  • src/ftinspect/glyphcomponents/glyphcontinuous.cpp
    ... ... @@ -552,6 +552,8 @@ GlyphContinuous::drawCacheGlyph(QPainter* painter,
    552 552
                                     const GlyphCacheEntry& entry,
    
    553 553
                                     bool colorInverted)
    
    554 554
     {
    
    555
    +  if (!entry.image)
    
    556
    +    return;
    
    555 557
       // From `ftview.c:557`.
    
    556 558
       // Well, metrics are also part of the cache...
    
    557 559
       int width = entry.advance.x ? entry.advance.x >> 16
    


  • reply via email to

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