From d35f8b74df6564514d05c4cc11e5176ae3cc1b5d Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sat, 24 Sep 2016 19:48:58 +0200 Subject: [PATCH] imageinfo_ni: Fix memory error Reported from AddressSanitizer (heap-use-after-free) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/517e5e7ceed9ea6e7ba3e31835465463f2608a91 Author: Michael Liebmann 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 --- src/gui/imageinfo_ni.cpp | 26 +++++++++++++------------- src/gui/imageinfo_ni.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gui/imageinfo_ni.cpp b/src/gui/imageinfo_ni.cpp index f6c6ccb55..eb8da53ae 100644 --- a/src/gui/imageinfo_ni.cpp +++ b/src/gui/imageinfo_ni.cpp @@ -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); } -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); } @@ -241,15 +241,15 @@ void CImageInfoNI::paint() CConfigFile config('\t'); config.loadConfig("/.version"); - const char * imagename = config.getString("imagename", "NI-Neutrino-HD").c_str(); - const char * homepage = config.getString("homepage", "www.neutrino-images.de").c_str(); - const char * creator = config.getString("creator", "NI-Team").c_str(); - const char * version = config.getString("version", "no version").c_str(); - const char * origin_commit = config.getString("origin-commit", "no commit").c_str(); - const char * builddate = config.getString("builddate", "no builddate").c_str(); + std::string imagename = config.getString("imagename", "NI-Neutrino-HD"); + std::string homepage = config.getString("homepage", "www.neutrino-images.de"); + std::string creator = config.getString("creator", "NI-Team"); + std::string version = config.getString("version", "no version"); + std::string origin_commit = config.getString("origin-commit", "no commit"); + std::string builddate = config.getString("builddate", "no builddate"); static CFlashVersionInfo versionInfo(version); - const char * releaseCycle = versionInfo.getReleaseCycle(); + std::string releaseCycle = versionInfo.getReleaseCycle(); struct utsname uts_info; @@ -262,11 +262,11 @@ void CImageInfoNI::paint() ypos += iheight; 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; paintLine(xpos , font_info, "Commit:"); - paintLine(xpos+offset, font_info, commits.str().c_str()); + paintLine(xpos+offset, font_info, commits.str()); ypos += iheight; paintLine(xpos , font_info, "Kernel:"); @@ -566,7 +566,7 @@ void CImageInfoNI::paint_DF_Info(int posx) get_DF_Info(); 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); pb.setFrameThickness(0); @@ -595,7 +595,7 @@ void CImageInfoNI::paint_DF_Info(int posx) } ypos+= sheight; - paintLine(posx, font_small, buf.str().c_str()); + paintLine(posx, font_small, buf.str()); buf.str(""); if (image_size.available > 1024) @@ -604,7 +604,7 @@ void CImageInfoNI::paint_DF_Info(int posx) buf << "Free: " << image_size.available << " KB"; ypos += sheight; - paintLine(posx, font_small, buf.str().c_str()); + paintLine(posx, font_small, buf.str()); } int CImageInfoNI::get_MEM_Info() diff --git a/src/gui/imageinfo_ni.h b/src/gui/imageinfo_ni.h index 025e19230..209a43a34 100644 --- a/src/gui/imageinfo_ni.h +++ b/src/gui/imageinfo_ni.h @@ -60,7 +60,7 @@ class CImageInfoNI : public CMenuTarget void paint(); 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); typedef struct {