From 9e036f142bd4a80f509f85de854280bfed70e9eb Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 26 Apr 2023 22:29:32 -0500 Subject: [PATCH] fix warn reports for buffer oveeruns also misc uninitialized vars --- Engine/source/console/codeBlock.cpp | 5 +++-- Engine/source/console/consoleFunctions.cpp | 2 +- Engine/source/console/consoleObject.h | 6 +++--- Engine/source/console/engineExports.h | 2 +- Engine/source/console/simSet.cpp | 1 + Engine/source/core/util/journal/journal.h | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Engine/source/console/codeBlock.cpp b/Engine/source/console/codeBlock.cpp index 46b40d441..62d089eff 100644 --- a/Engine/source/console/codeBlock.cpp +++ b/Engine/source/console/codeBlock.cpp @@ -309,7 +309,7 @@ void CodeBlock::calcBreakList() if (seqCount) size++; - breakList = new U32[size]; + breakList = new U32[size+3]; breakListSize = size; line = -1; seqCount = 0; @@ -434,7 +434,7 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st) st.read(&lineBreakPairCount); U32 totSize = codeLength + lineBreakPairCount * 2; - code = new U32[totSize]; + code = new U32[totSize+1]; // 0xFF is used as a flag to help compress the bytecode. // If detected, the bytecode is only a U8. @@ -1301,6 +1301,7 @@ void CodeBlock::dumpInstructions(U32 startIp, bool upToReturn) case FuncCallExprNode::MethodCall: callTypeName = "MethodCall"; break; case FuncCallExprNode::ParentCall: callTypeName = "ParentCall"; break; case FuncCallExprNode::StaticCall: callTypeName = "StaticCall"; break; + default: callTypeName = "INVALID"; break; } Con::printf("%i: OP_CALLFUNC stk=+1 name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace, callTypeName); diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index 7ec077950..4d9d29f42 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -146,7 +146,7 @@ bool isFloat(const char* str, bool sciOk = false) } break; case '.': - if(seenDot | (sciOk && eLoc != -1)) + if(seenDot || (sciOk && eLoc != -1)) return false; seenDot = true; break; diff --git a/Engine/source/console/consoleObject.h b/Engine/source/console/consoleObject.h index aa4e372ab..b21322b32 100644 --- a/Engine/source/console/consoleObject.h +++ b/Engine/source/console/consoleObject.h @@ -682,7 +682,7 @@ public: T::initPersistFields(); T::consoleInit(); - EnginePropertyTable::Property* props = new EnginePropertyTable::Property[sg_tempFieldList.size()]; + EnginePropertyTable::Property* props = new EnginePropertyTable::Property[sg_tempFieldList.size() + 1]; for (int i = 0; i < sg_tempFieldList.size(); ++i) { @@ -825,7 +825,7 @@ class ConsoleObject : public EngineObject protected: /// @deprecated This is disallowed. - ConsoleObject(const ConsoleObject&); + ConsoleObject(const ConsoleObject&) { mDocsClick = false; }; public: /// @@ -863,7 +863,7 @@ public: public: /// Get the classname from a class tag. - static const char* lookupClassName(const U32 in_classTag); + static const char* lookupClassName(const U32 in_classTag) {}; /// @name Fields /// @{ diff --git a/Engine/source/console/engineExports.h b/Engine/source/console/engineExports.h index fba5943d3..1303315f8 100644 --- a/Engine/source/console/engineExports.h +++ b/Engine/source/console/engineExports.h @@ -166,7 +166,7 @@ class EngineExportScope : public EngineExport private: /// Constructor for the global scope. - EngineExportScope(){} + EngineExportScope():mExports(NULL){} }; diff --git a/Engine/source/console/simSet.cpp b/Engine/source/console/simSet.cpp index bce5cd47d..075899e48 100644 --- a/Engine/source/console/simSet.cpp +++ b/Engine/source/console/simSet.cpp @@ -890,6 +890,7 @@ DefineEngineMethod( SimSet, listObjects, void, (),, for(itr = object->begin(); itr != object->end(); itr++) { SimObject *obj = *itr; + if (obj == nullptr) continue; bool isSet = dynamic_cast(obj) != 0; const char *name = obj->getName(); if(name) diff --git a/Engine/source/core/util/journal/journal.h b/Engine/source/core/util/journal/journal.h index a6b0b8957..cc1b2c921 100644 --- a/Engine/source/core/util/journal/journal.h +++ b/Engine/source/core/util/journal/journal.h @@ -352,8 +352,8 @@ class Journal template struct MethodRep: public FuncDecl { - typename T::ObjPtr obj; - typename T::MethodPtr method; + typename T::ObjPtr obj = NULL; + typename T::MethodPtr method = NULL; virtual bool match(VoidPtr ptr,VoidMethod func) const { return obj == (typename T::ObjPtr)ptr && method == (typename T::MethodPtr)func; }