mirror of https://github.com/neutrinolabs/xrdp
fix crash when font file dosen't exist
This commit is contained in:
parent
a7df159ce9
commit
df49056579
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue