fb: Fix possible NULL pointer de-reference

ftpr assignment is being done before checking fb->fonts pointer.
Just changing assignment position.

Fixes 23299 [1]

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2020-03-16 15:03:30 -07:00 committed by Maureen Helm
parent 36ec040473
commit 841b6ab990

View file

@ -106,12 +106,14 @@ static u8_t draw_char_vtmono(const struct char_framebuffer *fb,
int cfb_print(struct device *dev, char *str, u16_t x, u16_t y)
{
const struct char_framebuffer *fb = &char_fb;
const struct cfb_font *fptr = &(fb->fonts[fb->font_idx]);
const struct cfb_font *fptr;
if (!fb->fonts || !fb->buf) {
return -1;
}
fptr = &(fb->fonts[fb->font_idx]);
if (fptr->height % 8) {
LOG_ERR("Wrong font size");
return -1;