mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
src/driver/fb_generic.cpp fix possible memleak and possible double free
This commit is contained in:
@@ -788,6 +788,7 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in
|
||||
return false;
|
||||
|
||||
int yy = y;
|
||||
bool freeicondata = false;
|
||||
//printf("CFrameBuffer::paintIcon: load %s\n", filename.c_str());fflush(stdout);
|
||||
|
||||
/* we cache and check original name */
|
||||
@@ -872,6 +873,8 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in
|
||||
cache_size += dsize;
|
||||
icon_cache.insert(std::pair <std::string, rawIcon> (filename, tmpIcon));
|
||||
//printf("Cached %s, cache size %d\n", newname.c_str(), cache_size);
|
||||
}else{
|
||||
freeicondata = true;
|
||||
}
|
||||
} else {
|
||||
data = it->second.data;
|
||||
@@ -880,9 +883,13 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in
|
||||
//printf("paintIcon: already cached %s %d x %d\n", newname.c_str(), width, height);
|
||||
}
|
||||
_display:
|
||||
if(!paint)
|
||||
if(!paint){
|
||||
if(freeicondata){
|
||||
free(data);
|
||||
data = NULL;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
if (h != 0)
|
||||
yy += (h - height) / 2;
|
||||
|
||||
@@ -1351,7 +1358,7 @@ void CFrameBuffer::useBackground(bool ub)
|
||||
useBackgroundPaint = ub;
|
||||
if(!useBackgroundPaint) {
|
||||
delete[] background;
|
||||
background=0;
|
||||
background=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1374,10 +1381,11 @@ void CFrameBuffer::saveBackgroundImage(void)
|
||||
|
||||
void CFrameBuffer::restoreBackgroundImage(void)
|
||||
{
|
||||
fb_pixel_t * tmp = background;
|
||||
fb_pixel_t * tmp = NULL;
|
||||
|
||||
if (backupBackground != NULL)
|
||||
{
|
||||
tmp = background;
|
||||
background = backupBackground;
|
||||
backupBackground = NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user