imageinfo_ni: Fix memory error

Reported from AddressSanitizer (heap-use-after-free)


Origin commit data
------------------
Branch: ni/coolstream
Commit: 517e5e7cee
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-09-24 (Sat, 24 Sep 2016)

Origin message was:
------------------
imageinfo_ni: Fix memory error

 Reported from AddressSanitizer (heap-use-after-free)


------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2016-09-24 19:48:58 +02:00
committed by vanhofen
parent 6d0b12b813
commit d35f8b74df
2 changed files with 14 additions and 14 deletions

View File

@@ -206,7 +206,7 @@ void CImageInfoNI::paint_pig(int px, int py, int w, int h)
g_PicViewer->DisplayImage(ICONSDIR "/start.jpg", px, py, w, h, frameBuffer->TM_NONE); g_PicViewer->DisplayImage(ICONSDIR "/start.jpg", px, py, w, h, frameBuffer->TM_NONE);
} }
void CImageInfoNI::paintLine(int xpos, int font, const char* text) void CImageInfoNI::paintLine(int xpos, int font, std::string text)
{ {
g_Font[font]->RenderString(xpos, ypos, max_text_width, text, COL_INFOBAR_TEXT); g_Font[font]->RenderString(xpos, ypos, max_text_width, text, COL_INFOBAR_TEXT);
} }
@@ -241,15 +241,15 @@ void CImageInfoNI::paint()
CConfigFile config('\t'); CConfigFile config('\t');
config.loadConfig("/.version"); config.loadConfig("/.version");
const char * imagename = config.getString("imagename", "NI-Neutrino-HD").c_str(); std::string imagename = config.getString("imagename", "NI-Neutrino-HD");
const char * homepage = config.getString("homepage", "www.neutrino-images.de").c_str(); std::string homepage = config.getString("homepage", "www.neutrino-images.de");
const char * creator = config.getString("creator", "NI-Team").c_str(); std::string creator = config.getString("creator", "NI-Team");
const char * version = config.getString("version", "no version").c_str(); std::string version = config.getString("version", "no version");
const char * origin_commit = config.getString("origin-commit", "no commit").c_str(); std::string origin_commit = config.getString("origin-commit", "no commit");
const char * builddate = config.getString("builddate", "no builddate").c_str(); std::string builddate = config.getString("builddate", "no builddate");
static CFlashVersionInfo versionInfo(version); static CFlashVersionInfo versionInfo(version);
const char * releaseCycle = versionInfo.getReleaseCycle(); std::string releaseCycle = versionInfo.getReleaseCycle();
struct utsname uts_info; struct utsname uts_info;
@@ -262,11 +262,11 @@ void CImageInfoNI::paint()
ypos += iheight; ypos += iheight;
paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_VERSION)); paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_VERSION));
paintLine(xpos+offset, font_info, imageversion.str().c_str()); paintLine(xpos+offset, font_info, imageversion.str());
ypos += iheight; ypos += iheight;
paintLine(xpos , font_info, "Commit:"); paintLine(xpos , font_info, "Commit:");
paintLine(xpos+offset, font_info, commits.str().c_str()); paintLine(xpos+offset, font_info, commits.str());
ypos += iheight; ypos += iheight;
paintLine(xpos , font_info, "Kernel:"); paintLine(xpos , font_info, "Kernel:");
@@ -566,7 +566,7 @@ void CImageInfoNI::paint_DF_Info(int posx)
get_DF_Info(); get_DF_Info();
buf << "Imagesize (" << image_size.percent << " Percent):"; buf << "Imagesize (" << image_size.percent << " Percent):";
paintLine(posx, font_small, buf.str().c_str()); paintLine(posx, font_small, buf.str());
CProgressBar pb(boxX, boxY, boxW, boxH); CProgressBar pb(boxX, boxY, boxW, boxH);
pb.setFrameThickness(0); pb.setFrameThickness(0);
@@ -595,7 +595,7 @@ void CImageInfoNI::paint_DF_Info(int posx)
} }
ypos+= sheight; ypos+= sheight;
paintLine(posx, font_small, buf.str().c_str()); paintLine(posx, font_small, buf.str());
buf.str(""); buf.str("");
if (image_size.available > 1024) if (image_size.available > 1024)
@@ -604,7 +604,7 @@ void CImageInfoNI::paint_DF_Info(int posx)
buf << "Free: " << image_size.available << " KB"; buf << "Free: " << image_size.available << " KB";
ypos += sheight; ypos += sheight;
paintLine(posx, font_small, buf.str().c_str()); paintLine(posx, font_small, buf.str());
} }
int CImageInfoNI::get_MEM_Info() int CImageInfoNI::get_MEM_Info()

View File

@@ -60,7 +60,7 @@ class CImageInfoNI : public CMenuTarget
void paint(); void paint();
void paint_pig(int x, int y, int w, int h); void paint_pig(int x, int y, int w, int h);
void paintLine(int xpos, int font, const char* text); void paintLine(int xpos, int font, std::string text);
void clearLine(int xpos, int font); void clearLine(int xpos, int font);
typedef struct { typedef struct {