mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 00:41:09 +02:00
pictureviewer: fix possible segfault if width or height < 1,fix possible memleak
Origin commit data
------------------
Commit: 5ea4cbf145
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2016-11-01 (Tue, 01 Nov 2016)
This commit is contained in:
@@ -616,6 +616,11 @@ void CPictureViewer::rescaleImageDimensions(int *width, int *height, const int m
|
|||||||
|
|
||||||
bool CPictureViewer::DisplayImage(const std::string & name, int posx, int posy, int width, int height, int transp)
|
bool CPictureViewer::DisplayImage(const std::string & name, int posx, int posy, int width, int height, int transp)
|
||||||
{
|
{
|
||||||
|
if(width < 1 || height < 1){
|
||||||
|
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: width %i height %i \n", __func__, __LINE__, width, height);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
CFrameBuffer* frameBuffer = CFrameBuffer::getInstance();
|
CFrameBuffer* frameBuffer = CFrameBuffer::getInstance();
|
||||||
if (transp > CFrameBuffer::TM_EMPTY)
|
if (transp > CFrameBuffer::TM_EMPTY)
|
||||||
frameBuffer->SetTransparent(transp);
|
frameBuffer->SetTransparent(transp);
|
||||||
@@ -672,6 +677,12 @@ fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width,
|
|||||||
if (load_ret == FH_ERROR_OK)
|
if (load_ret == FH_ERROR_OK)
|
||||||
{
|
{
|
||||||
dprintf(DEBUG_INFO, "[CPictureViewer] [%s - %d] mode %s, decoded %s, (Pos: %d %d) ,bpp = %d \n", __func__, __LINE__, mode_str.c_str(), name.c_str(), x, y, bpp);
|
dprintf(DEBUG_INFO, "[CPictureViewer] [%s - %d] mode %s, decoded %s, (Pos: %d %d) ,bpp = %d \n", __func__, __LINE__, mode_str.c_str(), name.c_str(), x, y, bpp);
|
||||||
|
// image size error
|
||||||
|
if((GetImage) && (*width < 1 || *height < 1)){
|
||||||
|
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode: %s, file: %s (Pos: %d %d, Dim: %d x %d)\n", __func__, __LINE__, mode_str.c_str(), name.c_str(), x, y, *width, *height);
|
||||||
|
free(buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
// resize only getImage
|
// resize only getImage
|
||||||
if ((GetImage) && (x != *width || y != *height))
|
if ((GetImage) && (x != *width || y != *height))
|
||||||
{
|
{
|
||||||
@@ -691,6 +702,7 @@ fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width,
|
|||||||
*height = y;
|
*height = y;
|
||||||
}else{
|
}else{
|
||||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode %s: Error decoding file %s\n", __func__, __LINE__, mode_str.c_str(), name.c_str());
|
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode %s: Error decoding file %s\n", __func__, __LINE__, mode_str.c_str(), name.c_str());
|
||||||
|
free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
Reference in New Issue
Block a user