changeset 869:48ebfc711a8c trunk

[svn] - guard some potentially improper double delete [] usage
author nenolod
date Fri, 16 Mar 2007 21:08:34 -0700
parents d889a20dd9b5
children 028350cb60b1
files ChangeLog src/adplug/core/a2m.cxx src/adplug/core/adl.cxx src/adplug/core/sng.h src/adplug/core/temuopl.cxx src/adplug/core/u6m.cxx src/adplug/core/xad.cxx src/adplug/core/xsm.cxx
diffstat 8 files changed, 30 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 16 18:58:17 2007 -0700
+++ b/ChangeLog	Fri Mar 16 21:08:34 2007 -0700
@@ -1,3 +1,12 @@
+2007-03-17 01:58:17 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [1836]
+  - fix double delete[] possibility.
+  
+  trunk/src/adplug/core/u6m.cxx |    4 ++--
+  trunk/src/adplug/core/u6m.h   |    2 +-
+  2 files changed, 3 insertions(+), 3 deletions(-)
+
+
 2007-03-17 01:58:10 +0000  Giacomo Lozito <james@develia.org>
   revision [1834]
   - last commit wasn't obviously related wit changes here; revert stuff that is still being tested
--- a/src/adplug/core/a2m.cxx	Fri Mar 16 18:58:17 2007 -0700
+++ b/src/adplug/core/a2m.cxx	Fri Mar 16 21:08:34 2007 -0700
@@ -138,8 +138,10 @@
   initspeed = *orgptr;
   // v5-8 files have an additional flag byte here
   if(ch.version == 1 || ch.version == 5)
-    delete [] org;
-  delete [] secdata;
+    {
+      delete [] org; org = 0;
+    }
+  delete [] secdata; secdata = 0;
 
   // blocks 1-4 or 1-8
   alength = len[1];
@@ -175,7 +177,7 @@
       if(ch.numpats > 56)
 	sixdepak(secptr,orgptr,len[8]);
     }
-    delete [] secdata;
+    delete [] secdata; secdata = 0;
   } else {
     org = (unsigned char *)secdata;
     for(l=0;l<alength;l++) org[l] = f->readInt(1);
@@ -234,9 +236,13 @@
   }
 
   if(ch.version == 1 || ch.version == 5)
-    delete [] org;
+    {
+      delete [] org; org = 0; 
+    }
   else
-    delete [] secdata;
+    {
+      delete [] secdata; secdata = 0;
+    }
   fp.close(f);
   rewind(0);
   return true;
@@ -444,6 +450,6 @@
 	wdbuf = source; obuf = dest;
 
 	decode();
-	delete [] buf;
+	if (buf) { delete [] buf; buf = 0; }
 	return output_size;
 }
--- a/src/adplug/core/adl.cxx	Fri Mar 16 18:58:17 2007 -0700
+++ b/src/adplug/core/adl.cxx	Fri Mar 16 21:08:34 2007 -0700
@@ -2218,8 +2218,8 @@
 }
 
 CadlPlayer::~CadlPlayer() {
-  delete [] _soundDataPtr;
-  delete _driver;
+  delete [] _soundDataPtr; _soundDataPtr = 0;
+  delete _driver; _driver = 0;
 }
 
 bool CadlPlayer::init() {
--- a/src/adplug/core/sng.h	Fri Mar 16 18:58:17 2007 -0700
+++ b/src/adplug/core/sng.h	Fri Mar 16 21:08:34 2007 -0700
@@ -32,8 +32,8 @@
 	CsngPlayer(Copl *newopl)
 		: CPlayer(newopl), data(0)
 	{ };
-	~CsngPlayer()
-	{ if(data) delete [] data; };
+
+	~CsngPlayer() { if(data) delete [] data; data = 0; };
 
 	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
--- a/src/adplug/core/temuopl.cxx	Fri Mar 16 18:58:17 2007 -0700
+++ b/src/adplug/core/temuopl.cxx	Fri Mar 16 21:08:34 2007 -0700
@@ -59,7 +59,7 @@
     for(i=0;i<(stereo ? samples*2 : samples);i++)
       ((char *)buf)[i] = (tempbuf[i] >> 8) ^ 0x80;
 
-    delete [] tempbuf;
+    delete [] tempbuf; tempbuf = 0;
   }
 }
 
--- a/src/adplug/core/u6m.cxx	Fri Mar 16 18:58:17 2007 -0700
+++ b/src/adplug/core/u6m.cxx	Fri Mar 16 21:08:34 2007 -0700
@@ -89,7 +89,7 @@
     }
 
     // deallocation section
-    delete[] compressed_song_data;
+    delete[] compressed_song_data; compressed_song_data = 0;
 
     rewind(0);
     return (true);
@@ -900,7 +900,7 @@
 
 Cu6mPlayer::MyDict::~MyDict()
 {
-  delete [] dictionary;
+  delete [] dictionary; dictionary = 0;
 }
 
 // re-initializes the dictionary
--- a/src/adplug/core/xad.cxx	Fri Mar 16 18:58:17 2007 -0700
+++ b/src/adplug/core/xad.cxx	Fri Mar 16 21:08:34 2007 -0700
@@ -31,8 +31,7 @@
 
 CxadPlayer::~CxadPlayer()
 {
-  if (tune)
-    delete [] tune;
+  if (tune) { delete [] tune; tune = 0; }
 }
 
 bool CxadPlayer::load(VFSFile *fd, const CFileProvider &fp)
--- a/src/adplug/core/xsm.cxx	Fri Mar 16 18:58:17 2007 -0700
+++ b/src/adplug/core/xsm.cxx	Fri Mar 16 21:08:34 2007 -0700
@@ -30,7 +30,7 @@
 
 CxsmPlayer::~CxsmPlayer()
 {
-  if(music) delete [] music;
+  if(music) { delete [] music; music = 0; }
 }
 
 bool CxsmPlayer::load(VFSFile *fd, const CFileProvider &fp)