fix crash when font file dosen't exist

This commit is contained in:
jsorg71 2008-08-26 05:12:24 +00:00
parent a7df159ce9
commit df49056579
2 changed files with 19 additions and 1 deletions

View File

@ -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)
{

View File

@ -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;