[Bf-blender-cvs] [09640ab2919] master: Fix T99872: Crash Loading Embedded Fonts - Master
Harley Acheson
noreply at git.blender.org
Tue Aug 16 21:45:22 CEST 2022
Commit: 09640ab2919c17f24e14c8d71fafdb15c4748395
Author: Harley Acheson
Date: Tue Aug 16 12:43:10 2022 -0700
Branches: master
https://developer.blender.org/rB09640ab2919c17f24e14c8d71fafdb15c4748395
Fix T99872: Crash Loading Embedded Fonts - Master
Commit rBc0845abd897f to 3.4 (master) uses font's filepath without
checking if it exists, therefore crashing on embedded fonts since
they do not have a filepath (loaded from memory).
See D15703 for more details
Differential Revision: https://developer.blender.org/D15703
Reviewed by Brecht Van Lommel
===================================================================
M source/blender/blenfont/intern/blf_font.c
===================================================================
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index b3729b7a673..226752bffd8 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -1384,22 +1384,27 @@ static FontBLF *blf_font_new_ex(const char *name,
BLI_mutex_init(&font->glyph_cache_mutex);
- /* If we have static details about this font we don't need to load the Face. */
- const eFaceDetails *static_details = NULL;
- char filename[256];
- for (int i = 0; i < (int)ARRAY_SIZE(static_face_details); i++) {
- BLI_split_file_part(font->filepath, filename, sizeof(filename));
- if (STREQ(static_face_details[i].name, filename)) {
- static_details = &static_face_details[i];
- font->UnicodeRanges[0] = static_details->coverage1;
- font->UnicodeRanges[1] = static_details->coverage2;
- font->UnicodeRanges[2] = static_details->coverage3;
- font->UnicodeRanges[3] = static_details->coverage4;
- break;
+ /* If we have static details about this font file, we don't have to load the Face yet. */
+ bool face_needed = true;
+
+ if (font->filepath) {
+ const eFaceDetails *static_details = NULL;
+ char filename[256];
+ for (int i = 0; i < (int)ARRAY_SIZE(static_face_details); i++) {
+ BLI_split_file_part(font->filepath, filename, sizeof(filename));
+ if (STREQ(static_face_details[i].name, filename)) {
+ static_details = &static_face_details[i];
+ font->UnicodeRanges[0] = static_details->coverage1;
+ font->UnicodeRanges[1] = static_details->coverage2;
+ font->UnicodeRanges[2] = static_details->coverage3;
+ font->UnicodeRanges[3] = static_details->coverage4;
+ face_needed = false;
+ break;
+ }
}
}
- if (!static_details) {
+ if (face_needed) {
if (!blf_ensure_face(font)) {
blf_font_free(font);
return NULL;
More information about the Bf-blender-cvs
mailing list