aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorinmarket <inmarket@ugfx.org>2016-10-01 18:54:18 +1000
committerinmarket <inmarket@ugfx.org>2016-10-01 18:54:18 +1000
commitb3ba618c2a62854288f976fc4eb5042070d5b63e (patch)
tree5c0fbe8cf7ad68cc7f8c298c5e3b9eb768388219 /src
parente3a0cff0008905a1a910694b18c62e8702dafc5d (diff)
downloaduGFX-b3ba618c2a62854288f976fc4eb5042070d5b63e.tar.gz
uGFX-b3ba618c2a62854288f976fc4eb5042070d5b63e.tar.bz2
uGFX-b3ba618c2a62854288f976fc4eb5042070d5b63e.zip
Add protection for a font not being supplied.
Diffstat (limited to 'src')
-rw-r--r--src/gdisp/gdisp.c18
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