From df49056579c9539af79a52fa561087c4d4f0deb5 Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Tue, 26 Aug 2008 05:12:24 +0000 Subject: [PATCH] fix crash when font file dosen't exist --- xrdp/xrdp_font.c | 6 ++++++ xrdp/xrdp_painter.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/xrdp/xrdp_font.c b/xrdp/xrdp_font.c index 7b143d43..68d62abd 100644 --- a/xrdp/xrdp_font.c +++ b/xrdp/xrdp_font.c @@ -79,6 +79,12 @@ xrdp_font_create(struct xrdp_wm* wm) DEBUG(("in xrdp_font_create")); g_snprintf(file_path, 255, "%s/%s", XRDP_SHARE_PATH, DEFAULT_FONT_NAME); + if (!g_file_exist(file_path)) + { + g_writeln("xrdp_font_create: error font file [%s] does not exist", + file_path); + return 0; + } file_size = g_file_get_size(file_path); if (file_size < 1) { diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c index f68627d1..ae487423 100644 --- a/xrdp/xrdp_painter.c +++ b/xrdp/xrdp_painter.c @@ -184,6 +184,10 @@ xrdp_painter_text_width(struct xrdp_painter* self, char* text) twchar* wstr; xrdp_painter_font_needed(self); + if (self->font == 0) + { + return 0; + } if (text == 0) { return 0; @@ -212,6 +216,10 @@ xrdp_painter_text_height(struct xrdp_painter* self, char* text) twchar* wstr; xrdp_painter_font_needed(self); + if (self->font == 0) + { + return 0; + } if (text == 0) { return 0; @@ -397,10 +405,14 @@ xrdp_painter_draw_text(struct xrdp_painter* self, { return 0; } + xrdp_painter_font_needed(self); + if (self->font == 0) + { + return 0; + } /* convert to wide char */ wstr = (twchar*)g_malloc((len + 2) * sizeof(twchar), 0); g_mbstowcs(wstr, text, len + 1); - xrdp_painter_font_needed(self); font = self->font; f = 0; k = 0;