mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 16:31:05 +02:00
fix needed mem check
Origin commit data
------------------
Commit: 833a65c9e4
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2017-03-23 (Thu, 23 Mar 2017)
This commit is contained in:
@@ -170,7 +170,8 @@ bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign,
|
||||
m_NextPic_Buffer = NULL;
|
||||
}
|
||||
size_t bufsize = x * y * 3;
|
||||
if (!checkfreemem(bufsize)){
|
||||
size_t resizeBuf = (m_endx - m_startx) * (m_endy - m_starty)*3;
|
||||
if (!checkfreemem(bufsize + resizeBuf)){
|
||||
return false;
|
||||
}
|
||||
m_NextPic_Buffer = (unsigned char *) malloc (bufsize);
|
||||
@@ -856,8 +857,8 @@ bool CPictureViewer::checkfreemem(size_t bufsize)
|
||||
{
|
||||
struct sysinfo info;
|
||||
sysinfo( &info );
|
||||
if(bufsize*2 + 4096 > (size_t)info.freeram + (size_t)info.freeswap){
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Out of memory\n", __func__, __LINE__);
|
||||
if(bufsize + 4096 > (size_t)info.freeram + (size_t)info.freeswap){
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Out of memory: need %zu > free %zu\n", __func__, __LINE__,bufsize,(size_t)info.freeram + (size_t)info.freeswap);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user