fix crash when font file dosen't exist

ulab-original
jsorg71 16 years ago
parent a7df159ce9
commit df49056579

@ -79,6 +79,12 @@ xrdp_font_create(struct xrdp_wm* wm)
DEBUG(("in xrdp_font_create")); DEBUG(("in xrdp_font_create"));
g_snprintf(file_path, 255, "%s/%s", XRDP_SHARE_PATH, DEFAULT_FONT_NAME); 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); file_size = g_file_get_size(file_path);
if (file_size < 1) if (file_size < 1)
{ {

@ -184,6 +184,10 @@ xrdp_painter_text_width(struct xrdp_painter* self, char* text)
twchar* wstr; twchar* wstr;
xrdp_painter_font_needed(self); xrdp_painter_font_needed(self);
if (self->font == 0)
{
return 0;
}
if (text == 0) if (text == 0)
{ {
return 0; return 0;
@ -212,6 +216,10 @@ xrdp_painter_text_height(struct xrdp_painter* self, char* text)
twchar* wstr; twchar* wstr;
xrdp_painter_font_needed(self); xrdp_painter_font_needed(self);
if (self->font == 0)
{
return 0;
}
if (text == 0) if (text == 0)
{ {
return 0; return 0;
@ -397,10 +405,14 @@ xrdp_painter_draw_text(struct xrdp_painter* self,
{ {
return 0; return 0;
} }
xrdp_painter_font_needed(self);
if (self->font == 0)
{
return 0;
}
/* convert to wide char */ /* convert to wide char */
wstr = (twchar*)g_malloc((len + 2) * sizeof(twchar), 0); wstr = (twchar*)g_malloc((len + 2) * sizeof(twchar), 0);
g_mbstowcs(wstr, text, len + 1); g_mbstowcs(wstr, text, len + 1);
xrdp_painter_font_needed(self);
font = self->font; font = self->font;
f = 0; f = 0;
k = 0; k = 0;

Loading…
Cancel
Save