Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-30 07:56:01 +0300
committerJeroen Bakker <jeroen@blender.org>2022-10-03 15:59:17 +0300
commit839edefaba11488086554f519645f66c974be452 (patch)
treee8c85d5d38a940a37646e24e0c44a5d5c85b23d3 /source/blender
parent25c593f5d1a7f895810f98d61d26c92d13de2991 (diff)
Fix error in blf_get_sample_text returning a pointer to stack memory
Copy-by-value was used when iterating over unicode_samples which then referenced an array from the value. Resolve by referencing a const pointer to the unicode_sample array.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenfont/intern/blf_thumbs.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c
index 2eed7418220..e4eed070e24 100644
--- a/source/blender/blenfont/intern/blf_thumbs.c
+++ b/source/blender/blenfont/intern/blf_thumbs.c
@@ -258,16 +258,18 @@ static const char32_t *blf_get_sample_text(FT_Face face)
count_bits_i((uint)os2_table->ulUnicodeRange4);
for (uint i = 0; i < ARRAY_SIZE(unicode_samples); ++i) {
- UnicodeSample s = unicode_samples[i];
- if (os2_table && s.field && s.mask) {
+ const UnicodeSample *s = &unicode_samples[i];
+ if (os2_table && s->field && s->mask) {
/* OS/2 Table contains 4 contiguous integers of script coverage bit flags. */
- FT_ULong *field = &(os2_table->ulUnicodeRange1) + (s.field - 1);
- if (!(*field & (FT_ULong)s.mask)) {
+ const FT_ULong *unicode_range = &os2_table->ulUnicodeRange1;
+ const size_t index = (s->field - 1);
+ BLI_assert(index < 4);
+ if (!(unicode_range[index] & (FT_ULong)s->mask)) {
continue;
}
}
- if (FT_Get_Char_Index(face, s.sample[0]) != 0) {
- sample = s.sample;
+ if (FT_Get_Char_Index(face, s->sample[0]) != 0) {
+ sample = s->sample;
break;
}
}