Browse Source

plugging found leaks

LEAK from G:\GameDev\GithubRepo\Torque3D\Engine\source\console/consoleObject.h:686
- leak around props remaining after the const_cast free it up

LEAK around sound asset
- assetEnumNameConcat was creating a leak.
marauder2k7 5 months ago
parent
commit
15ff382469
2 changed files with 9 additions and 2 deletions
  1. 6 1
      Engine/source/T3D/assets/SoundAsset.h
  2. 3 1
      Engine/source/console/consoleObject.h

+ 6 - 1
Engine/source/T3D/assets/SoundAsset.h

@@ -516,7 +516,12 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\
    else Con::warnf("Warning: %s::LOAD_SOUNDASSET_ARRAY(%s[%i])-%s", mClassName, m##name##AssetId[index], index, ImageAsset::getAssetErrstrn(assetState).c_str());\
    else Con::warnf("Warning: %s::LOAD_SOUNDASSET_ARRAY(%s[%i])-%s", mClassName, m##name##AssetId[index], index, ImageAsset::getAssetErrstrn(assetState).c_str());\
 }
 }
 
 
-#define assetEnumNameConcat(x,suff)(new std::string( x + std::string(#suff)))->c_str()
+#define assetEnumNameConcat(x, suff) ([](const char* base) { \
+         String result = String(base) + #suff; \
+         char* ret = Con::getReturnBuffer(result.length() + 1); \
+         dStrcpy(ret, result.c_str(), result.length() + 1); \
+         return ret; \
+      })(x)
 
 
 #define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \
 #define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \
    for (U32 i = 0; i < maxValue; i++)\
    for (U32 i = 0; i < maxValue; i++)\

+ 3 - 1
Engine/source/console/consoleObject.h

@@ -705,7 +705,9 @@ public:
       smPropertyTable = _smPropertyTable;
       smPropertyTable = _smPropertyTable;
 
 
       const_cast<EngineTypeInfo*>(mTypeInfo)->mPropertyTable = &_smPropertyTable;
       const_cast<EngineTypeInfo*>(mTypeInfo)->mPropertyTable = &_smPropertyTable;
- 
+
+      // After we hand it off, immediately delete if safe:
+      delete[] props;
       // Let the base finish up.
       // Let the base finish up.
       AbstractClassRep::init();
       AbstractClassRep::init();
    }
    }