From f8a6890f552c259bc013cd30198fd7521897bd84 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Tue, 16 Apr 2019 23:15:57 +0200 Subject: [PATCH] fix check mmap error, avoid possible segment fault Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/7d5b7d92795490d892a9f196755eb74faf079ab4 Author: Jacek Jendrzej Date: 2019-04-16 (Tue, 16 Apr 2019) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/video.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index 0cf60bb..068ac81 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -1066,7 +1066,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; @@ -1091,7 +1090,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: \n"); close(fb);