Merge pull request #66033 from timothyqiu/ft-done

Fix crash when executing `FontFile.get_face_count`
This commit is contained in:
Rémi Verschelde 2022-09-18 10:52:53 +02:00
commit 48caf73198
2 changed files with 4 additions and 4 deletions

View file

@ -1940,12 +1940,12 @@ int64_t TextServerAdvanced::font_get_face_count(const RID &p_font_rid) const {
fargs.flags = FT_OPEN_MEMORY; fargs.flags = FT_OPEN_MEMORY;
fargs.stream = &stream; fargs.stream = &stream;
FT_Face tmp_face; FT_Face tmp_face = nullptr;
error = FT_Open_Face(ft_library, &fargs, -1, &tmp_face); error = FT_Open_Face(ft_library, &fargs, -1, &tmp_face);
if (error == 0) { if (error == 0) {
face_count = tmp_face->num_faces; face_count = tmp_face->num_faces;
FT_Done_Face(tmp_face);
} }
FT_Done_Face(tmp_face);
#endif #endif
} }

View file

@ -1039,12 +1039,12 @@ int64_t TextServerFallback::font_get_face_count(const RID &p_font_rid) const {
fargs.flags = FT_OPEN_MEMORY; fargs.flags = FT_OPEN_MEMORY;
fargs.stream = &stream; fargs.stream = &stream;
FT_Face tmp_face; FT_Face tmp_face = nullptr;
error = FT_Open_Face(ft_library, &fargs, -1, &tmp_face); error = FT_Open_Face(ft_library, &fargs, -1, &tmp_face);
if (error == 0) { if (error == 0) {
face_count = tmp_face->num_faces; face_count = tmp_face->num_faces;
FT_Done_Face(tmp_face);
} }
FT_Done_Face(tmp_face);
#endif #endif
} }