diff options
author | inmarket <inmarket@ugfx.org> | 2016-10-01 18:54:18 +1000 |
---|---|---|
committer | inmarket <inmarket@ugfx.org> | 2016-10-01 18:54:18 +1000 |
commit | b3ba618c2a62854288f976fc4eb5042070d5b63e (patch) | |
tree | 5c0fbe8cf7ad68cc7f8c298c5e3b9eb768388219 /src/gdisp | |
parent | e3a0cff0008905a1a910694b18c62e8702dafc5d (diff) | |
download | uGFX-b3ba618c2a62854288f976fc4eb5042070d5b63e.tar.gz uGFX-b3ba618c2a62854288f976fc4eb5042070d5b63e.tar.bz2 uGFX-b3ba618c2a62854288f976fc4eb5042070d5b63e.zip |
Add protection for a font not being supplied.
Diffstat (limited to 'src/gdisp')
-rw-r--r-- | src/gdisp/gdisp.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c index 3925bbee..691cab85 100644 --- a/src/gdisp/gdisp.c +++ b/src/gdisp/gdisp.c @@ -3202,6 +3202,8 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co #endif void gdispGDrawChar(GDisplay *g, coord_t x, coord_t y, uint16_t c, font_t font, color_t color) { + if (!font) + return; MUTEX_ENTER(g); g->t.font = font; g->t.clipx0 = x; @@ -3215,6 +3217,8 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co } void gdispGFillChar(GDisplay *g, coord_t x, coord_t y, uint16_t c, font_t font, color_t color, color_t bgcolor) { + if (!font) + return; MUTEX_ENTER(g); g->p.cx = mf_character_width(font, c) + font->baseline_x; g->p.cy = font->height; @@ -3235,6 +3239,8 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co } void gdispGDrawString(GDisplay *g, coord_t x, coord_t y, const char *str, font_t font, color_t color) { + if (!font) + return; MUTEX_ENTER(g); g->t.font = font; g->t.clipx0 = x; @@ -3249,6 +3255,8 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co } void gdispGFillString(GDisplay *g, coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor) { + if (!font) + return; MUTEX_ENTER(g); g->p.cx = mf_get_string_width(font, str, 0, 0) + font->baseline_x; g->p.cy = font->height; @@ -3275,6 +3283,8 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co uint16_t nbrLines; #endif + if (!font) + return; MUTEX_ENTER(g); g->t.font = font; @@ -3326,6 +3336,8 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co uint16_t nbrLines; #endif + if (!font) + return; MUTEX_ENTER(g); g->p.cx = cx; @@ -3382,6 +3394,8 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co } coord_t gdispGetFontMetric(font_t font, fontmetric_t metric) { + if (!font) + return 0; /* No mutex required as we only read static data */ switch(metric) { case fontHeight: return font->height; @@ -3397,12 +3411,14 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co } coord_t gdispGetCharWidth(char c, font_t font) { + if (!font) + return 0; /* No mutex required as we only read static data */ return mf_character_width(font, c); } coord_t gdispGetStringWidthCount(const char* str, font_t font, uint16_t count) { - if (!str) + if (!str || !font) return 0; // No mutex required as we only read static data |