From 726e6a6ce32b7203355da80b9f35f42653c47c06 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Tue, 22 Dec 2009 15:39:54 +0000 Subject: [PATCH] is safe to deallocate a NULL pointer git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@115 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/148c0a771a3d3c36939c52707689f85c11f2305d Author: Jacek Jendrzej Date: 2009-12-22 (Tue, 22 Dec 2009) ------------------ This commit was generated by Migit --- src/driver/framebuffer.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index 08091cfd9..644bae734 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -264,10 +264,12 @@ CFrameBuffer::~CFrameBuffer() { if (background) { delete[] background; + background = NULL; } if (backupBackground) { delete[] backupBackground; + backupBackground = NULL; } #if 0 @@ -285,8 +287,10 @@ CFrameBuffer::~CFrameBuffer() if (lfb) munmap(lfb, available); - if (virtual_fb) + if (virtual_fb){ delete[] virtual_fb; + virtual_fb = NULL; + } close(fd); close(tty); } @@ -1286,9 +1290,10 @@ bool CFrameBuffer::loadBackgroundPic(const std::string & filename, bool show) return true; //printf("loadBackgroundPic: %s\n", filename.c_str()); - if (background) + if (background){ delete[] background; - + background = NULL; + } background = g_PicViewer->getImage(iconBasePath + filename, BACKGROUNDIMAGEWIDTH, 576); if (background == NULL) { @@ -1320,9 +1325,10 @@ bool CFrameBuffer::getuseBackground(void) void CFrameBuffer::saveBackgroundImage(void) { - if (backupBackground != NULL) + if (backupBackground != NULL){ delete[] backupBackground; - + backupBackground = NULL; + } backupBackground = background; //useBackground(false); // <- necessary since no background is available useBackgroundPaint = false; @@ -1341,8 +1347,10 @@ void CFrameBuffer::restoreBackgroundImage(void) else useBackground(false); // <- necessary since no background is available - if (tmp != NULL) + if (tmp != NULL){ delete[] tmp; + tmp = NULL; + } } void CFrameBuffer::paintBackgroundBoxRel(int x, int y, int dx, int dy)