On hidpi screens, label-freetype will trigger a use-after-free in
set_font_for_control() via the call in update_scale_factor_from_pixel_buffer().
That call passes label->font as the font parameter to set_font_for_control().
set_font_for_control() then calls strdup() on its font argument, and
frees label->font. In this case this causes font to point into freed
memory, causing a read use-after-free in the following strstr() and
strrchr() calls.
Fix the issue by only using the freshly strdup()'d new_font variable
after freeing label->font.
free (label->font);
label->font = new_font;
- if (strstr (font, "Mono") || strstr (font, "mono")) {
+ if (strstr (new_font, "Mono") || strstr (new_font, "mono")) {
if (!label->is_monospaced) {
FT_Done_Face (label->face);
FT_Done_Face (label->bold_face);
/* Format is "Family 1[,Family 2[,..]] [25[px]]" .
* [] means optional. */
- size_str = strrchr (font, ' ');
+ size_str = strrchr (new_font, ' ');
if (size_str) {
unsigned long parsed_size;