fix check mmap error, avoid possible segment fault

This commit is contained in:
Jacek Jendrzej
2019-01-13 20:13:55 +01:00
parent 4730206966
commit cf1884f1fc

View File

@@ -1014,7 +1014,6 @@ void get_osd_size(int &xres, int &yres, int &bits_per_pixel)
}
void get_osd_buf(unsigned char *osd_data)
{
unsigned char *lfb = NULL;
struct fb_fix_screeninfo fix_screeninfo;
struct fb_var_screeninfo var_screeninfo;
@@ -1039,7 +1038,8 @@ void get_osd_buf(unsigned char *osd_data)
return;
}
if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
void *lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0);
if(lfb == MAP_FAILED)
{
fprintf(stderr, "Framebuffer: <Memmapping failed>\n");
close(fb);