mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +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;
|
return false;
|
||||||
|
|
||||||
int yy = y;
|
int yy = y;
|
||||||
|
bool freeicondata = false;
|
||||||
//printf("CFrameBuffer::paintIcon: load %s\n", filename.c_str());fflush(stdout);
|
//printf("CFrameBuffer::paintIcon: load %s\n", filename.c_str());fflush(stdout);
|
||||||
|
|
||||||
/* we cache and check original name */
|
/* 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;
|
cache_size += dsize;
|
||||||
icon_cache.insert(std::pair <std::string, rawIcon> (filename, tmpIcon));
|
icon_cache.insert(std::pair <std::string, rawIcon> (filename, tmpIcon));
|
||||||
//printf("Cached %s, cache size %d\n", newname.c_str(), cache_size);
|
//printf("Cached %s, cache size %d\n", newname.c_str(), cache_size);
|
||||||
|
}else{
|
||||||
|
freeicondata = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data = it->second.data;
|
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);
|
//printf("paintIcon: already cached %s %d x %d\n", newname.c_str(), width, height);
|
||||||
}
|
}
|
||||||
_display:
|
_display:
|
||||||
if(!paint)
|
if(!paint){
|
||||||
|
if(freeicondata){
|
||||||
|
free(data);
|
||||||
|
data = NULL;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
if (h != 0)
|
if (h != 0)
|
||||||
yy += (h - height) / 2;
|
yy += (h - height) / 2;
|
||||||
|
|
||||||
@@ -1351,7 +1358,7 @@ void CFrameBuffer::useBackground(bool ub)
|
|||||||
useBackgroundPaint = ub;
|
useBackgroundPaint = ub;
|
||||||
if(!useBackgroundPaint) {
|
if(!useBackgroundPaint) {
|
||||||
delete[] background;
|
delete[] background;
|
||||||
background=0;
|
background=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1374,10 +1381,11 @@ void CFrameBuffer::saveBackgroundImage(void)
|
|||||||
|
|
||||||
void CFrameBuffer::restoreBackgroundImage(void)
|
void CFrameBuffer::restoreBackgroundImage(void)
|
||||||
{
|
{
|
||||||
fb_pixel_t * tmp = background;
|
fb_pixel_t * tmp = NULL;
|
||||||
|
|
||||||
if (backupBackground != NULL)
|
if (backupBackground != NULL)
|
||||||
{
|
{
|
||||||
|
tmp = background;
|
||||||
background = backupBackground;
|
background = backupBackground;
|
||||||
backupBackground = NULL;
|
backupBackground = NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user