Skip to content

Commit 1eaceb4

Browse files
msalaunashif
authored andcommitted
cfb: Skip non-existent font glyphs
The change ensures that returned glyph exists in the current font. Signed-off-by: Maksim Salau <[email protected]>
1 parent c5d7f93 commit 1eaceb4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

subsys/fb/cfb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ static struct char_framebuffer char_fb;
6969

7070
static inline uint8_t *get_glyph_ptr(const struct cfb_font *fptr, uint8_t c)
7171
{
72+
if (c < fptr->first_char || c > fptr->last_char) {
73+
return NULL;
74+
}
75+
7276
return (uint8_t *)fptr->data +
7377
(c - fptr->first_char) *
7478
(fptr->width * fptr->height / 8U);

0 commit comments

Comments
 (0)