ecsv avatar ecsv committed 45b80cf

Don't access random memory in TxFilter constructor

Comments (0)

Files changed (1)

src/GlideHQ/TxFilter.cpp

 {
   /* clear hires texture cache */
   delete _txHiResCache;
+  _txHiResCache = NULL;
 
   /* clear texture cache */
   delete _txTexCache;
+  _txTexCache = NULL;
 
   /* free memory */
   TxMemBuf::getInstance()->shutdown();
 
   /* clear other stuff */
   delete _txImage;
+  _txImage = NULL;
   delete _txQuantize;
+  _txQuantize = NULL;
   delete _txUtil;
+  _txUtil = NULL;
 }
 
 TxFilter::~TxFilter()
 
 TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options,
                    int cachesize, wchar_t *path, wchar_t *ident,
-                   dispInfoFuncExt callback)
+                   dispInfoFuncExt callback) :
+  _numcore(1), _tex1(NULL), _tex2(NULL), _maxwidth(0), _maxheight(0),
+  _maxbpp(0), _options(0), _cacheSize(0), _ident(), _path(), _txQuantize(NULL),
+  _txTexCache(NULL), _txHiResCache(NULL), _txUtil(NULL), _txImage(NULL),
+  _initialized(false)
 {
-  /* HACKALERT: the emulator misbehaves and sometimes forgets to shutdown */
-  if ((ident && wcscmp(ident, L"DEFAULT") != 0 && _ident.compare(ident) == 0) &&
-      _maxwidth  == maxwidth  &&
-      _maxheight == maxheight &&
-      _maxbpp    == maxbpp    &&
-      _options   == options   &&
-      _cacheSize == cachesize) return;
   clear(); /* gcc does not allow the destructor to be called */
 
   /* shamelessness :P this first call to the debug output message creates
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.