diff --git a/source/gui/GUIbase.cpp b/source/gui/GUIbase.cpp index 34d37eb3fa..2cab7f9df6 100644 --- a/source/gui/GUIbase.cpp +++ b/source/gui/GUIbase.cpp @@ -97,7 +97,7 @@ bool CClientArea::SetClientArea(const CStr& Value) if (!line.m_ParseOK) return false; - int arg_count[4]; // argument counts for the four values + int arg_count[4] = {0,0,0,0}; // argument counts for the four values int arg_start[4] = {0,0,0,0}; // location of first argument, [0] is always 0 // Divide into the four piles (delimiter is an argument named "delim") diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index 94e3461c33..5d7b4d4e44 100644 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -578,6 +578,7 @@ void CConsole::SetBuffer(const wchar_t* szMessage) FlushBuffer(); wcsncpy(m_szBuffer, szMessage, CONSOLE_BUFFER_SIZE); + m_szBuffer[CONSOLE_BUFFER_SIZE-1] = 0; m_iBufferLength = (int)wcslen(m_szBuffer); m_iBufferPos = std::min(oldBufferPos, m_iBufferLength); } diff --git a/source/ps/Overlay.cpp b/source/ps/Overlay.cpp index 28d79aca25..dae01025a3 100644 --- a/source/ps/Overlay.cpp +++ b/source/ps/Overlay.cpp @@ -41,8 +41,7 @@ bool CColor::ParseString(const CStr8& Value, float DefaultAlpha) // TODO Gee: Parsing failed return false; } - float values[4]; - values[3] = DefaultAlpha; + float values[4] = { 0, 0, 0, DefaultAlpha }; for (int i=0; i<(int)line.GetArgCount(); ++i) { if (!line.GetArgFloat(i, values[i])) diff --git a/source/ps/ProfileViewer.cpp b/source/ps/ProfileViewer.cpp index a469b6c9de..1e0990acb3 100644 --- a/source/ps/ProfileViewer.cpp +++ b/source/ps/ProfileViewer.cpp @@ -439,6 +439,9 @@ namespace f << "\n\n" << table->GetTitle() << "\n"; + if (cols == 0) // avoid divide-by-zero + return; + for (size_t r = 0; r < data.size()/cols; ++r) { for (size_t c = 0; c < cols; ++c) diff --git a/source/ps/Profiler2GPU.cpp b/source/ps/Profiler2GPU.cpp index 05a257ef40..2a8834175a 100644 --- a/source/ps/Profiler2GPU.cpp +++ b/source/ps/Profiler2GPU.cpp @@ -659,14 +659,14 @@ private: if (counter.type == INTEL_PERFQUERIES_TYPE_UNSIGNED_INT) { ENSURE(counter.size == 4); - GLuint value; + GLuint value = 0; memcpy(&value, buf + counter.offset, counter.size); m_Storage.RecordAttributePrintf("%s: %u", counter.name.c_str(), value); } else if (counter.type == INTEL_PERFQUERIES_TYPE_UNSIGNED_INT64) { ENSURE(counter.size == 8); - GLuint64 value; + GLuint64 value = 0; memcpy(&value, buf + counter.offset, counter.size); m_Storage.RecordAttributePrintf("%s: %.0f", counter.name.c_str(), (double)value); @@ -676,14 +676,14 @@ private: else if (counter.type == INTEL_PERFQUERIES_TYPE_FLOAT) { ENSURE(counter.size == 4); - GLfloat value; + GLfloat value = 0; memcpy(&value, buf + counter.offset, counter.size); m_Storage.RecordAttributePrintf("%s: %f", counter.name.c_str(), value); } else if (counter.type == INTEL_PERFQUERIES_TYPE_BOOL) { ENSURE(counter.size == 4); - GLuint value; + GLuint value = 0; memcpy(&value, buf + counter.offset, counter.size); ENSURE(value == 0 || value == 1); m_Storage.RecordAttributePrintf("%s: %u", counter.name.c_str(), value); diff --git a/source/ps/Replay.cpp b/source/ps/Replay.cpp index f7a22adb8c..4928996a44 100644 --- a/source/ps/Replay.cpp +++ b/source/ps/Replay.cpp @@ -249,4 +249,6 @@ void CReplayPlayer::Replay() delete &g_Profiler; delete &g_ProfileViewer; + + g_Game = NULL; } diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index ea5bc99d30..e889386fc6 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -1476,7 +1476,7 @@ void CRenderer::RenderSubmissions() if (waterScissor.GetVolume() > 0 && m_WaterManager->WillRenderFancyWater()) { PROFILE3_GPU("water scissor"); - SScreenRect dirty; + SScreenRect dirty = { 0, 0, 0, 0 }; if (m_Options.m_WaterRefraction && m_Options.m_WaterReflection) { SScreenRect reflectionScissor = RenderReflections(context, waterScissor); diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index b5b346fe68..034e1a871d 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/source/scriptinterface/ScriptVal.cpp b/source/scriptinterface/ScriptVal.cpp index f395695086..8cad9d0645 100644 --- a/source/scriptinterface/ScriptVal.cpp +++ b/source/scriptinterface/ScriptVal.cpp @@ -83,13 +83,14 @@ JSIdArray* AutoJSIdArray::get() const size_t AutoJSIdArray::length() const { - ENSURE(m_IdArray); + if (!m_IdArray) + return 0; return m_IdArray->length; } jsid AutoJSIdArray::operator[](size_t i) const { - ENSURE(m_IdArray); - ENSURE(i < (size_t)m_IdArray->length); + if (!(m_IdArray && i < (size_t)m_IdArray->length)) + return JSID_VOID; return m_IdArray->vector[i]; } diff --git a/source/simulation2/components/CCmpRangeManager.cpp b/source/simulation2/components/CCmpRangeManager.cpp index 45ff98bbaa..9c74edf9e9 100644 --- a/source/simulation2/components/CCmpRangeManager.cpp +++ b/source/simulation2/components/CCmpRangeManager.cpp @@ -1449,6 +1449,10 @@ public: } } } + + if (overallVisibleVertices == 0) // avoid divide-by-zero + return 0; + return exploredVertices * 100 / overallVisibleVertices; } }; diff --git a/source/tools/atlas/GameInterface/GameLoop.cpp b/source/tools/atlas/GameInterface/GameLoop.cpp index 1c4d44f791..d545d83b90 100644 --- a/source/tools/atlas/GameInterface/GameLoop.cpp +++ b/source/tools/atlas/GameInterface/GameLoop.cpp @@ -327,6 +327,7 @@ bool BeginAtlas(const CmdLineArgs& args, const DllLoader& dll) // Clean up AtlasView::DestroyViews(); ScriptingHost::FinalShutdown(); + AtlasMessage::g_MessagePasser = NULL; return true; }