freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][gsoc-2022-chariri] * src/ftinspect/engine


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][gsoc-2022-chariri] * src/ftinspect/engine/engine.cpp: Fix crash on changing glyph index after
Date: Thu, 07 Jul 2022 18:12:54 +0000

Charlie Jiang pushed to branch gsoc-2022-chariri at FreeType / FreeType Demo Programs

Commits:

  • 7a22072e
    by Charlie Jiang at 2022-07-08T02:03:14+08:00
    * src/ftinspect/engine/engine.cpp: Fix crash on changing glyph index after
    changing size quickly.
    
    When changing glyph index, the glyph name will be request by calling
    `Engine::glyphName`, which uses the cached `ftSize_`. However, `ftSize_` which
    is set by `FTC_Manager_LookupSize`, is not guaranteed to survive after other
    `FTC_ImageCache_LookupScaler` calls (called when the size changes).
    
    When one changes the size quickly (especially by Shift+MouseWheel), the object
    the old `ftSize_` points to is actually freed by `FTC_Manager_LookupSize`
    because the element count reachs the limit in the internal MRU caches.
    Therefore the `ftSize_` becomes a dangling pointer, causing crash when
    navigating to other glyphs.
    
    This bug was not so apparent before because one couldn't change the size so
    quickly, so memory allocating were maybe less frequent, and the dangling
    pointer still holds valid data. But more intense test still can reveal this.
    
    The solution here is simple, just lookup `ftSize_` again before fetching the
    glyph name.
    

1 changed file:

Changes:

  • src/ftinspect/engine/engine.cpp
    ... ... @@ -339,6 +339,9 @@ Engine::glyphName(int index)
    339 339
       if (index < 0)
    
    340 340
         throw std::runtime_error("Invalid glyph index");
    
    341 341
     
    
    342
    +   if (!FTC_Manager_LookupSize(cacheManager_, &scaler_, &ftSize_))
    
    343
    +    return name;
    
    344
    +
    
    342 345
       if (ftSize_ && FT_HAS_GLYPH_NAMES(ftSize_->face))
    
    343 346
       {
    
    344 347
         char buffer[256];
    


  • reply via email to

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