瀏覽代碼

uninitialized variables-console

AzaezelX 5 年之前
父節點
當前提交
2c1508c169

+ 1 - 0
Engine/source/console/astNodes.cpp

@@ -142,6 +142,7 @@ StmtNode::StmtNode()
 {
    mNext = NULL;
    dbgFileName = CodeBlock::smCurrentParser->getCurrentFile();
+   dbgLineNumber = 0;
 }
 
 void StmtNode::setPackage(StringTableEntry)

+ 3 - 0
Engine/source/console/codeBlock.cpp

@@ -56,6 +56,9 @@ CodeBlock::CodeBlock()
    name = NULL;
    fullPath = NULL;
    modPath = NULL;
+   codeSize = 0;
+   lineBreakPairCount = 0;
+   nextFile = NULL;
 }
 
 CodeBlock::~CodeBlock()

+ 3 - 0
Engine/source/console/codeInterpreter.cpp

@@ -224,6 +224,9 @@ CodeInterpreter::CodeInterpreter(CodeBlock *cb) :
    mSaveCodeBlock(nullptr),
    mCurrentInstruction(0)
 {
+   dMemset(&mExec, 0, sizeof(mExec));
+   dMemset(&mObjectCreationStack, 0, sizeof(mObjectCreationStack));
+   dMemset(&mNSDocBlockClass, 0, sizeof(mNSDocBlockClass));
 }
 
 CodeInterpreter::~CodeInterpreter()

+ 1 - 1
Engine/source/console/compiler.h

@@ -317,7 +317,7 @@ protected:
       U32 addr;  ///< Address to patch
       U32 value; ///< Value to place at addr
 
-      PatchEntry() { ; }
+      PatchEntry(): addr(0), value(0) { ; }
       PatchEntry(U32 a, U32 v) : addr(a), value(v) { ; }
    } PatchEntry;
 

+ 12 - 1
Engine/source/console/consoleInternal.cpp

@@ -475,7 +475,7 @@ Dictionary::Entry::Entry(StringTableEntry in_name)
    nextEntry = NULL;
    mUsage = NULL;
    mIsConstant = false;
-
+   mNext = NULL;
    // NOTE: This is data inside a nameless
    // union, so we don't need to init the rest.
    value.init();
@@ -856,6 +856,7 @@ ExprEvalState::ExprEvalState()
    stack.reserve(64);
    mShouldReset = false;
    mResetLocked = false;
+   copyVariable = NULL;
 }
 
 ExprEvalState::~ExprEvalState()
@@ -927,6 +928,15 @@ Namespace::Entry::Entry()
    mUsage = NULL;
    mHeader = NULL;
    mNamespace = NULL;
+   cb.mStringCallbackFunc = NULL;
+   mFunctionLineNumber = 0;
+   mFunctionName = StringTable->EmptyString();
+   mFunctionOffset = 0;
+   mMinArgs = 0;
+   mMaxArgs = 0;
+   mNext = NULL;
+   mPackage = StringTable->EmptyString();
+   mToolOnly = false;
 }
 
 void Namespace::Entry::clear()
@@ -959,6 +969,7 @@ Namespace::Namespace()
    mHashSequence = 0;
    mRefCountToParent = 0;
    mClassRep = 0;
+   lastUsage = NULL;
 }
 
 Namespace::~Namespace()

+ 1 - 0
Engine/source/console/consoleInternal.h

@@ -306,6 +306,7 @@ public:
          nextEntry = NULL;
          mUsage = NULL;
          mIsConstant = false;
+         mNext = NULL;
          value.init();
       }
 

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

@@ -220,7 +220,21 @@ public:
       : Parent( sizeof( void* ), conIdPtr, typeName )
    {
       VECTOR_SET_ASSOCIATION( mFieldList );
-
+      mCategory = StringTable->EmptyString();
+      mClassGroupMask = 0;
+      std::fill_n(mClassId, NetClassGroupsCount, -1);
+      mClassName = StringTable->EmptyString();
+      mClassSizeof = 0;
+      mClassType = 0;
+      mDescription = StringTable->EmptyString();
+#ifdef TORQUE_NET_STATS
+      dMemset(mDirtyMaskFrequency, 0, sizeof(mDirtyMaskFrequency));
+      dMemset(mDirtyMaskTotal, 0, sizeof(mDirtyMaskTotal));
+#endif
+      mDynamicGroupExpand = false;
+      mNamespace = NULL;
+      mNetEventDir = 0;
+      nextClass = NULL;
       parentClass  = NULL;
       mIsRenderEnabled = true;
       mIsSelectionEnabled = true;
@@ -496,6 +510,7 @@ public:
             validator( NULL ),
             setDataFn( NULL ),
             getDataFn( NULL ),
+            writeDataFn(NULL),
             networkMask(0)
       {
          doNotSubstitute = keepClearSubsOnly = false;

+ 1 - 1
Engine/source/console/engineAPI.h

@@ -1190,7 +1190,7 @@ public:
    ConsoleValueRef _exec();
    ConsoleValueRef _execLater(SimConsoleThreadExecEvent *evt);
 
-   _BaseEngineConsoleCallbackHelper() {;}
+   _BaseEngineConsoleCallbackHelper(): mThis(NULL), mInitialArgc(0), mArgc(0), mCallbackName(StringTable->EmptyString()){;}
 };
 
 

+ 2 - 1
Engine/source/console/engineExports.h

@@ -123,6 +123,7 @@ class EngineExport : public StaticEngineObject
          : mExportName( "" ),
            mExportKind( EngineExportKindScope ),
            mExportScope( NULL ),
+           mDocString(""),
            mNextExport( NULL ) {}
 };
 
@@ -165,7 +166,7 @@ class EngineExportScope : public EngineExport
    private:
    
       /// Constructor for the global scope.
-      EngineExportScope() {}
+      EngineExportScope():mExports(NULL){}
 };
 
 

+ 1 - 1
Engine/source/console/engineObject.cpp

@@ -53,7 +53,7 @@ void*& _USERDATA( EngineObject* object )
 //-----------------------------------------------------------------------------
 
 EngineObject::EngineObject()
-   : mEngineObjectUserData( NULL )
+   : mEngineObjectPool(NULL), mEngineObjectUserData( NULL )
 {
    #ifdef TORQUE_DEBUG
    // Add to instance list.

+ 1 - 0
Engine/source/console/engineTypeInfo.cpp

@@ -58,6 +58,7 @@ EngineTypeInfo::EngineTypeInfo( const char* typeName, EngineExportScope* scope,
      mEnumTable( NULL ),
      mFieldTable( NULL ),
      mPropertyTable( NULL ),
+     mArgumentTypeTable(NULL),
      mSuperType( NULL ),
      mNext( smFirst )
 {

+ 1 - 0
Engine/source/console/simDatablock.cpp

@@ -55,6 +55,7 @@ ConsoleDocClass( SimDataBlock,
 
 SimDataBlock::SimDataBlock()
 {
+   modifiedKey = 0;
    setModDynamicFields(true);
    setModStaticFields(true);
 }

+ 2 - 0
Engine/source/console/simDictionary.cpp

@@ -31,6 +31,8 @@ SimNameDictionary::SimNameDictionary()
 {
 #ifndef USE_NEW_SIMDICTIONARY
    hashTable = NULL;
+   hashTableSize = DefaultTableSize;
+   hashEntryCount = 0;
 #endif
    mutex = Mutex::createMutex();
 }

+ 1 - 1
Engine/source/console/simEvents.h

@@ -62,7 +62,7 @@ public:
    ///  of addition to the list.
    SimObject *destObject;   ///< Object on which this event will be applied.
 
-   SimEvent() { destObject = NULL; }
+   SimEvent() { nextEvent = NULL; startTime = 0; time = 0; sequenceCount = 0; destObject = NULL; }
    virtual ~SimEvent() {}   ///< Destructor
    ///
    /// A dummy virtual destructor is required

+ 2 - 2
Engine/source/console/simFieldDictionary.h

@@ -47,7 +47,7 @@ class SimFieldDictionary
 public:
    struct Entry
    {
-      Entry() : type(NULL) {};
+      Entry() : slotName(StringTable->EmptyString()), value(NULL), next(NULL), type(NULL) {};
 
       StringTableEntry slotName;
       char *value;
@@ -112,4 +112,4 @@ public:
 };
 
 
-#endif // _SIMFIELDDICTIONARY_H_
+#endif // _SIMFIELDDICTIONARY_H_

+ 1 - 0
Engine/source/console/simObject.cpp

@@ -1380,6 +1380,7 @@ SimObject::SimObject(const SimObject& other, bool temp_clone)
    nextIdObject = other.nextIdObject;
    mGroup = other.mGroup;
    mFlags = other.mFlags;
+   mProgenitorFile = other.mProgenitorFile;
    mCopySource = other.mCopySource;
    mFieldDictionary = other.mFieldDictionary;
    //mIdString = other.mIdString; // special treatment (see below)

+ 6 - 0
Engine/source/console/stringStack.cpp

@@ -30,7 +30,12 @@ StringStack::StringStack()
    mBuffer = NULL;
    mArgBufferSize = 0;
    mArgBuffer = NULL;
+   for (U32 i = 0; i < MaxArgs; i++)
+      mArgV[i] = "";
+   dMemset(mFrameOffsets, 0, sizeof(mFrameOffsets));
+   dMemset(mStartOffsets, 0, sizeof(mStartOffsets));
    mNumFrames = 0;
+   mArgc = 0;
    mStart = 0;
    mLen = 0;
    mStartStackSize = 0;
@@ -232,6 +237,7 @@ mStackPos(0)
       mStack[i].init();
       mStack[i].type = ConsoleValue::TypeInternalString;
    }
+   dMemset(mStackFrames, 0, sizeof(mStackFrames));
 }
 
 ConsoleValueStack::~ConsoleValueStack()

+ 3 - 0
Engine/source/console/telnetConsole.cpp

@@ -88,6 +88,9 @@ TelnetConsole::TelnetConsole()
    mAcceptPort = -1;
    mClientList = NULL;
    mRemoteEchoEnabled = false;
+
+   dStrncpy(mTelnetPassword, "", PasswordMaxLength);
+   dStrncpy(mListenPassword, "", PasswordMaxLength);
 }
 
 TelnetConsole::~TelnetConsole()

+ 1 - 0
Engine/source/console/telnetConsole.h

@@ -78,6 +78,7 @@ class TelnetConsole
       S32 state;                       ///< State of the client.
                                        ///  @see TelnetConsole::State
       TelnetClient *nextClient;
+      TelnetClient() { dStrncpy(curLine, "", Con::MaxLineLength); curPos = 0; state = 0; nextClient = NULL; }
    };
    TelnetClient *mClientList;
    TelnetConsole();

+ 3 - 0
Engine/source/console/telnetDebugger.cpp

@@ -163,6 +163,9 @@ TelnetDebugger::TelnetDebugger()
    mProgramPaused = false;
    mWaitForClient = false;
 
+   dStrncpy(mDebuggerPassword, "", PasswordMaxLength);
+   dStrncpy(mLineBuffer, "", sizeof(mLineBuffer));
+   
    // Add the version number in a global so that
    // scripts can detect the presence of the
    // "enhanced" debugger features.

+ 2 - 1
Engine/source/console/typeValidators.h

@@ -27,7 +27,8 @@ class TypeValidator
 {
    public:
    S32 fieldIndex;
-
+   TypeValidator() : fieldIndex(0) {}
+   ~TypeValidator() {}
    /// Prints a console error message for the validator.
    ///
    /// The message is prefaced with with:

+ 1 - 1
Engine/source/core/color.h

@@ -203,7 +203,7 @@ public:
 class StockColorItem
 {
 private:
-   StockColorItem() {}
+   StockColorItem():mColorName("") {}
 
 public:
    StockColorItem( const char* pName, const U8 red, const U8 green, const U8 blue, const U8 alpha = 255 )

+ 1 - 0
Engine/source/core/frameAllocator.h

@@ -295,6 +295,7 @@ public:
       AssertFatal( count > 0, "Allocating a FrameTemp with less than one instance" ); \
       mWaterMark = FrameAllocator::getWaterMark(); \
       mMemory = reinterpret_cast<type *>( FrameAllocator::alloc( sizeof( type ) * count ) ); \
+      mNumObjectsInMemory = 0; \
    } \
    template<>\
    inline FrameTemp<type>::~FrameTemp() \