【问题标题】:FreeType2 load char crashes with sigsegvFreeType2 load char 与 sigsegv 崩溃
【发布时间】:2021-08-06 17:23:52
【问题描述】:
Breakpoint 1, fruit::FreetypeFontfaceLoader::bitmap (handle=0x5555555c58e0, char_index=65)
    at lib/./freetype_fontface_loader.hpp:42
42                              FT_Load_Char(handle, char_index, FT_LOAD_RENDER);
(gdb) print *handle
$1 = {num_faces = 1, face_index = 0, face_flags = 2649, style_flags = 0, num_glyphs = 6253, 
  family_name = 0x5555555c6520 "DejaVu Sans", style_name = 0x5555555c6a30 "Book", num_fixed_sizes = 0, 
  available_sizes = 0x0, num_charmaps = 5, charmaps = 0x5555555c6a80, generic = {data = 0x0, finalizer = 0x0}, 
  bbox = {xMin = -2090, yMin = -948, xMax = 3673, yMax = 2524}, units_per_EM = 2048, ascender = 1901, 
  descender = -483, height = 2384, max_advance_width = 3838, max_advance_height = 2384, underline_position = -175, 
  underline_thickness = 90, glyph = 0x5555555ef830, size = 0x5555555f80b0, charmap = 0x5555555c6980, 
  driver = 0x5555555b6100, memory = 0x5555555b5f50, stream = 0x5555555c29b0, sizes_list = {head = 0x5555555c2240, 
    tail = 0x5555555c2240}, autohint = {data = 0x0, finalizer = 0x0}, extensions = 0x0, internal = 0x5555555de5c0}
(gdb) step

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ed7718 in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
==10991== Invalid read of size 4
==10991==    at 0x491B718: ??? (in /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1)
==10991==    by 0x491B857: ??? (in /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1)
==10991==    by 0x48DBA6F: FT_Get_Char_Index (in /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1)
==10991==    by 0x48E1444: FT_Load_Char (in /usr/lib/x86_64-linux-gnu/libfreetype.so.6.17.1)
==10991==    by 0x10D0E5: fruit::FreetypeFontfaceLoader::bitmap(FT_FaceRec_*, unsigned int) (freetype_fontface_loader.hpp:43)

之前的调用:

FT_Face face{};
if(FT_New_Memory_Face(m_handle, reinterpret_cast<FT_Byte const*>(src_buffer.data()), src_buffer.size(), 0, &face) != FT_Err_Ok)
{
    throw FreetypeLoadError{};
}

handle = face;
FT_Set_Pixel_Sizes(handle, 0, 16);

显然,我做错了什么。

【问题讨论】:

    标签: freetype2


    【解决方案1】:

    显然,我错过了 API 的一个细节:

    在调用 FT_Done_Face 之前,您不得释放内存。

    不释放缓冲区可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-28
      • 2011-06-25
      • 1970-01-01
      • 1970-01-01
      • 2019-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多