Переглянути джерело

[MERGE #5272 @Penguinwizzard] Address issues picked up by Dev15 code analysis

Merge pull request #5272 from Penguinwizzard:dev15_prefast_fixes

This is one of the things that was preventing us from moving our jenkins CI to dev15.
Derek Morris 7 роки тому
батько
коміт
7368d59b1c
73 змінених файлів з 239 додано та 117 видалено
  1. 1 1
      bin/External/catch.hpp
  2. 1 1
      bin/GCStress/StubExternalApi.cpp
  3. 2 2
      bin/GCStress/WeightedTable.h
  4. 5 1
      bin/NativeTests/CodexTests.cpp
  5. 1 1
      bin/NativeTests/FileLoadHelpers.cpp
  6. 4 0
      bin/NativeTests/FunctionExecutionTest.cpp
  7. 1 0
      bin/NativeTests/FunctionExecutionTest.h
  8. 4 0
      bin/NativeTests/JsDiagApiTest.cpp
  9. 7 1
      bin/NativeTests/JsRTApiTest.cpp
  10. 4 0
      bin/NativeTests/MemoryPolicyTest.cpp
  11. 4 0
      bin/NativeTests/NativeTests.cpp
  12. 4 0
      bin/NativeTests/ThreadServiceTest.cpp
  13. 4 0
      bin/NativeTests/UnicodeTextTests.cpp
  14. 6 6
      bin/ch/Debugger.cpp
  15. 1 0
      bin/ch/HostConfigFlags.cpp
  16. 1 1
      bin/ch/JITProcessManager.cpp
  17. 9 7
      bin/ch/RuntimeThreadData.cpp
  18. 2 1
      bin/ch/WScriptJsrt.cpp
  19. 1 1
      bin/ch/ch.cpp
  20. 15 0
      bin/rl/rl.h
  21. 2 0
      bin/rl/xmlreader.h
  22. 9 11
      lib/Backend/Lower.cpp
  23. 1 0
      lib/Common/Codex/Utf8Codex.cpp
  24. 32 22
      lib/Common/Core/CriticalSection.h
  25. 6 0
      lib/Common/Core/EtwTraceCore.h
  26. 23 12
      lib/Common/DataStructures/BaseDictionary.h
  27. 4 1
      lib/Common/Memory/LargeHeapBlock.cpp
  28. 1 0
      lib/Common/Memory/LeakReport.cpp
  29. 1 0
      lib/Common/Memory/MarkContext.cpp
  30. 6 5
      lib/Common/PlatformAgnostic/DateTimeInternal.h
  31. 11 0
      lib/Common/Warnings.h
  32. 4 0
      lib/JITClient/JITManager.cpp
  33. 1 1
      lib/JITServer/JITServer.cpp
  34. 2 2
      lib/Runtime/Base/CrossSiteObject.h
  35. 2 2
      lib/Runtime/Base/FunctionBody.cpp
  36. 1 0
      lib/Runtime/Base/FunctionExecutionStateMachine.cpp
  37. 1 1
      lib/Runtime/Debug/TTInflateMap.cpp
  38. 2 1
      lib/Runtime/Language/JavascriptOperators.cpp
  39. 1 1
      lib/Runtime/Language/JavascriptOperators.h
  40. 1 1
      lib/Runtime/Language/ModuleNamespace.h
  41. 1 1
      lib/Runtime/Language/SimdBool32x4OperationX86X64.cpp
  42. 1 0
      lib/Runtime/Library/AtomicsObject.cpp
  43. 1 1
      lib/Runtime/Library/BoundFunction.cpp
  44. 1 1
      lib/Runtime/Library/BoundFunction.h
  45. 1 1
      lib/Runtime/Library/GlobalObject.cpp
  46. 1 1
      lib/Runtime/Library/GlobalObject.h
  47. 1 1
      lib/Runtime/Library/JavascriptFunction.cpp
  48. 1 1
      lib/Runtime/Library/JavascriptFunction.h
  49. 1 1
      lib/Runtime/Library/JavascriptGeneratorFunction.cpp
  50. 1 1
      lib/Runtime/Library/JavascriptGeneratorFunction.h
  51. 10 3
      lib/Runtime/Library/JavascriptProxy.cpp
  52. 1 1
      lib/Runtime/Library/JavascriptProxy.h
  53. 1 1
      lib/Runtime/Library/ModuleRoot.cpp
  54. 1 1
      lib/Runtime/Library/ModuleRoot.h
  55. 1 1
      lib/Runtime/Library/SharedArrayBuffer.cpp
  56. 2 2
      lib/Runtime/Library/SharedArrayBuffer.h
  57. 3 0
      lib/Runtime/Math/AsmJsMath.cpp
  58. 2 2
      lib/Runtime/Types/DeferredTypeHandler.h
  59. 6 1
      lib/Runtime/Types/DictionaryTypeHandler.cpp
  60. 1 1
      lib/Runtime/Types/DictionaryTypeHandler.h
  61. 1 1
      lib/Runtime/Types/DynamicObject.h
  62. 1 1
      lib/Runtime/Types/DynamicType.cpp
  63. 1 1
      lib/Runtime/Types/ES5ArrayTypeHandler.cpp
  64. 1 1
      lib/Runtime/Types/ES5ArrayTypeHandler.h
  65. 1 1
      lib/Runtime/Types/PathTypeHandler.cpp
  66. 1 1
      lib/Runtime/Types/PathTypeHandler.h
  67. 1 1
      lib/Runtime/Types/RecyclableObject.cpp
  68. 1 1
      lib/Runtime/Types/RecyclableObject.h
  69. 1 1
      lib/Runtime/Types/SpreadArgument.h
  70. 1 1
      lib/Runtime/Types/TypeHandler.h
  71. 1 1
      lib/Runtime/Types/WithScopeObject.h
  72. 1 0
      lib/WasmReader/WasmBinaryReader.cpp
  73. 1 1
      lib/wabt/src/color.cc

+ 1 - 1
bin/External/catch.hpp

@@ -7374,7 +7374,7 @@ namespace Catch {
             return TestCaseInfo::None;
     }
     inline bool isReservedTag( std::string const& tag ) {
-        return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( tag[0] );
+        return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( (unsigned char)tag[0] );
     }
     inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
         if( isReservedTag( tag ) ) {

+ 1 - 1
bin/GCStress/StubExternalApi.cpp

@@ -9,7 +9,7 @@
 
 bool ConfigParserAPI::FillConsoleTitle(__ecount(cchBufferSize) LPWSTR buffer, size_t cchBufferSize, __in LPWSTR moduleName)
 {
-    swprintf_s(buffer, cchBufferSize, _u("Chakra GC: %d - %s"), GetCurrentProcessId(), moduleName);
+    swprintf_s(buffer, cchBufferSize, _u("Chakra GC: %lu - %s"), GetCurrentProcessId(), moduleName);
 
     return true;
 }

+ 2 - 2
bin/GCStress/WeightedTable.h

@@ -13,14 +13,14 @@ template <class T>
 class WeightedTable
 {
 public:
-    WeightedTable() :
+    WeightedTable() noexcept :
         entries(nullptr), size(0)
     {
     }
 
     void AddWeightedEntry(T value, unsigned int weight)
     {
-        T * newEntries = static_cast<T *>(realloc(entries, (size + weight) * sizeof(T)));
+        T * newEntries = static_cast<T *>(realloc(entries, ((size_t)size + weight) * sizeof(T)));
         if (newEntries == nullptr)
         {
             // Should throw something better

+ 5 - 1
bin/NativeTests/CodexTests.cpp

@@ -3,6 +3,10 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "stdafx.h"
+#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
+#pragma warning(disable:26439) // Implicit noexcept
+#pragma warning(disable:26451) // Arithmetic overflow
+#pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
 #include <process.h>
 #include "Codex\Utf8Codex.h"
@@ -280,4 +284,4 @@ namespace CodexTest
         
         RunUtf8DecodeTestCase(testCases, utf8::DecodeUnitsIntoAndNullTerminateNoAdvance);
     }
-};
+};

+ 1 - 1
bin/NativeTests/FileLoadHelpers.cpp

@@ -114,7 +114,7 @@ HRESULT FileLoadHelpers::LoadScriptFromFile(LPCSTR filename, LPCWSTR& contents,
         utf8::DecodeOptions decodeOptions = utf8::doAllowInvalidWCHARs;
 
         UINT cUtf16Chars = utf8::ByteIndexIntoCharacterIndex(pRawBytes, lengthBytes, decodeOptions);
-        contents = (LPCWSTR)HeapAlloc(GetProcessHeap(), 0, (cUtf16Chars + 1) * sizeof(WCHAR));
+        contents = (LPCWSTR)HeapAlloc(GetProcessHeap(), 0, (cUtf16Chars + (size_t)1) * sizeof(WCHAR));
         if (nullptr == contents)
         {
             fwprintf(stderr, _u("out of memory"));

+ 4 - 0
bin/NativeTests/FunctionExecutionTest.cpp

@@ -3,6 +3,10 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "stdafx.h"
+#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
+#pragma warning(disable:26439) // Implicit noexcept
+#pragma warning(disable:26451) // Arithmetic overflow
+#pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
 #include "FunctionExecutionTest.h"
 

+ 1 - 0
bin/NativeTests/FunctionExecutionTest.h

@@ -6,6 +6,7 @@
 // This file contains stubs needed to make FunctionExecutionTest successfully compile and link as well
 // as a means to emulate behavior of objects that interact with FunctionExecutionStateMachine
 
+#include "..\..\lib\Common\Warnings.h"
 #include "..\..\lib\Common\Core\CommonMinMax.h"
 
 #define ENUM_CLASS_HELPERS(x, y)

+ 4 - 0
bin/NativeTests/JsDiagApiTest.cpp

@@ -4,6 +4,10 @@
 //-------------------------------------------------------------------------------------------------------
 
 #include "stdafx.h"
+#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
+#pragma warning(disable:26439) // Implicit noexcept
+#pragma warning(disable:26451) // Arithmetic overflow
+#pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
 #include <process.h>
 

+ 7 - 1
bin/NativeTests/JsRTApiTest.cpp

@@ -3,9 +3,14 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "stdafx.h"
+#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
+#pragma warning(disable:26439) // Implicit noexcept
+#pragma warning(disable:26451) // Arithmetic overflow
+#pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
 #include <array>
 #include <process.h>
+#include <suppress.h>
 
 #pragma warning(disable:4100) // unreferenced formal parameter
 #pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs
@@ -1243,7 +1248,8 @@ namespace JsRTApiTest
             size_t length;
             REQUIRE(JsStringToPointer(nameValue, &name, &length) == JsNoError);
 
-            CHECK(length == 1);
+            REQUIRE(length == 1);
+#pragma prefast(suppress:__WARNING_MAYBE_UNINIT_VAR, "The require on the previous line should ensure that name[0] is initialized")
             CHECK(name[0] == ('a' + index));
         }
     }

+ 4 - 0
bin/NativeTests/MemoryPolicyTest.cpp

@@ -3,6 +3,10 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "stdafx.h"
+#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
+#pragma warning(disable:26439) // Implicit noexcept
+#pragma warning(disable:26451) // Arithmetic overflow
+#pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
 
 #pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs

+ 4 - 0
bin/NativeTests/NativeTests.cpp

@@ -9,6 +9,10 @@
 // conversion from 'int' to 'char', possible loss of data
 #pragma warning(disable:4242)
 #pragma warning(disable:4244)
+#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
+#pragma warning(disable:26439) // Implicit noexcept
+#pragma warning(disable:26451) // Arithmetic overflow
+#pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
 #pragma warning(pop)
 

+ 4 - 0
bin/NativeTests/ThreadServiceTest.cpp

@@ -4,6 +4,10 @@
 //-------------------------------------------------------------------------------------------------------
 
 #include "stdafx.h"
+#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
+#pragma warning(disable:26439) // Implicit noexcept
+#pragma warning(disable:26451) // Arithmetic overflow
+#pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
 
 #pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs

+ 4 - 0
bin/NativeTests/UnicodeTextTests.cpp

@@ -4,6 +4,10 @@
 //-------------------------------------------------------------------------------------------------------
 
 #include "stdafx.h"
+#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
+#pragma warning(disable:26439) // Implicit noexcept
+#pragma warning(disable:26451) // Arithmetic overflow
+#pragma warning(disable:26495) // Uninitialized member variable
 #include "catch.hpp"
 
 namespace UnicodeTextTest

+ 6 - 6
bin/ch/Debugger.cpp

@@ -306,7 +306,7 @@ bool Debugger::SetBaseline()
 #ifdef _WIN32
     LPSTR script = nullptr;
     FILE *file = nullptr;
-    int numChars = 0;
+    size_t numChars = 0;
     HRESULT hr = S_OK;
 
     if (_wfopen_s(&file, HostConfigFlags::flags.dbgbaseline, _u("rb")) != 0)
@@ -316,13 +316,13 @@ bool Debugger::SetBaseline()
 
     if(file != nullptr)
     {
-        int fileSize = _filelength(_fileno(file));
-        if (fileSize <= MAX_BASELINE_SIZE)
+        long fileSize = _filelength(_fileno(file));
+        if (0 <= fileSize && fileSize <= MAX_BASELINE_SIZE)
         {
-            script = new char[fileSize + 1];
+            script = new char[(size_t)fileSize + 1];
 
-            numChars = static_cast<int>(fread(script, sizeof(script[0]), fileSize, file));
-            if (numChars == fileSize)
+            numChars = fread(script, sizeof(script[0]), fileSize, file);
+            if (numChars == (size_t)fileSize)
             {
                 script[numChars] = '\0';
 

+ 1 - 0
bin/ch/HostConfigFlags.cpp

@@ -96,6 +96,7 @@ void HostConfigFlags::RemoveArg(int& argc, _Inout_updates_to_(argc, argc) LPWSTR
     Assert(index >= 0 && index < argc);
     for (int i = index + 1; i < argc; ++i)
     {
+#pragma prefast(suppress:__WARNING_READ_OVERRUN, "Operation is safe but PREfast is difficult to convince")
         argv[i - 1] = argv[i];
     }
     --argc;

+ 1 - 1
bin/ch/JITProcessManager.cpp

@@ -52,7 +52,7 @@ HRESULT JITProcessManager::CreateServerProcess(int argc, __in_ecount(argc) LPWST
     STARTUPINFOW si = { 0 };
 
     // overallocate constant cmd line (jshost -jitserver:<guid>)
-    size_t cmdLineSize = (MAX_PATH + argc) * sizeof(WCHAR);
+    size_t cmdLineSize = (MAX_PATH + (size_t)argc) * sizeof(WCHAR);
     for (int i = 0; i < argc; ++i)
     {
         // calculate space requirement for each arg

+ 9 - 7
bin/ch/RuntimeThreadData.cpp

@@ -20,19 +20,21 @@ RuntimeThreadLocalData& GetRuntimeThreadLocalData()
     return threadLocalData;
 }
 
-RuntimeThreadData::RuntimeThreadData()
+RuntimeThreadData::RuntimeThreadData() :
+    hSemaphore(nullptr), 
+    hThread(nullptr),
+    sharedContent(nullptr),
+    receiveBroadcastCallbackFunc(nullptr),
+    runtime(nullptr),
+    context(nullptr),
+    parent(nullptr),
+    leaving(false)
 {
     this->hevntInitialScriptCompleted = CreateEvent(NULL, TRUE, FALSE, NULL);
     this->hevntReceivedBroadcast = CreateEvent(NULL, FALSE, FALSE, NULL);
     this->hevntShutdown = CreateEvent(NULL, TRUE, FALSE, NULL);
 
-    this->sharedContent = nullptr;
-    this->receiveBroadcastCallbackFunc = nullptr;
-
-    this->leaving = false;
-
     InitializeCriticalSection(&csReportQ);
-
 }
 
 RuntimeThreadData::~RuntimeThreadData()

+ 2 - 1
bin/ch/WScriptJsrt.cpp

@@ -35,6 +35,7 @@
 #endif // FreeBSD or unix ?
 #endif // _WIN32 ?
 
+#pragma prefast(disable:26444, "This warning unfortunately raises false positives when auto is used for declaring the type of an iterator in a loop.")
 #ifdef HAS_ICU
 #define INTL_LIBRARY_TEXT "icu"
 #elif defined(_WIN32)
@@ -133,7 +134,7 @@ JsValueRef __stdcall WScriptJsrt::EchoCallback(JsValueRef callee, bool isConstru
                 }
                 charcount_t len;
                 LPWSTR ws = str.GetWideString(&len);
-                LPWSTR wsNoNull = new WCHAR[len + 1];
+                LPWSTR wsNoNull = new WCHAR[((size_t)len) + 1];
                 charcount_t newIndex = 0;
                 for (charcount_t j = 0; j < len; j++)
                 {

+ 1 - 1
bin/ch/ch.cpp

@@ -145,7 +145,7 @@ void __stdcall PrintChakraCoreVersion()
                 // Doesn't matter if you are on 32 bit or 64 bit,
                 // DWORD is always 32 bits, so first two revision numbers
                 // come from dwFileVersionMS, last two come from dwFileVersionLS
-                wprintf(_u("%s version %u.%u.%u.%u\n"),
+                wprintf(_u("%s version %lu.%lu.%lu.%lu\n"),
                     chakraDllName,
                     (verInfo->dwFileVersionMS >> 16) & 0xffff,
                     (verInfo->dwFileVersionMS >> 0) & 0xffff,

+ 15 - 0
bin/rl/rl.h

@@ -21,7 +21,22 @@
 #include "xmlreader.h"
 #include "rlfeint.h"
 
+// Note that some of these look pretty bad, and are; this is a test host, so
+// we're not as concerned here.
 #pragma warning(disable:4127) // expression is constant, e.g., while(TRUE)
+#pragma warning(disable:6001) // using uninitialized memory
+#pragma warning(disable:6011) // dereferencing null pointer, potentially
+#pragma warning(disable:6031) // ignoring return value from some system calls
+#pragma warning(disable:6054) // string may not be zero-terminated
+#pragma warning(disable:6271) // Extra parameter not used by format string
+#pragma warning(disable:6262) // Function using too much stack for analyzer to look at it
+#pragma warning(disable:6335) // leaking process information handle
+#pragma warning(disable:6386) // Potential buffer overrun
+#pragma warning(disable:6387) // Potential misadherance to specification of library functions
+#pragma warning(disable:26439) // implicit noexcept
+#pragma warning(disable:26451) // Arithmetic on smaller type before widening conversion
+#pragma warning(disable:26495) // uninitialized member
+#pragma warning(disable:28193) // ignoring value that must be examined
 
 #define LOCAL static
 typedef __int32 int32;

+ 2 - 0
bin/rl/xmlreader.h

@@ -15,6 +15,8 @@
 namespace Xml
 {
 
+#pragma prefast(disable:26439) // implicit noexcept
+#pragma prefast(disable:26495) // uninitialized member variable
 
 // May want Unicode someday.
 

+ 9 - 11
lib/Backend/Lower.cpp

@@ -10519,7 +10519,7 @@ Lowerer::LowerStLoopBodyCount(IR::Instr* instr)
     IR::MemRefOpnd *loopBodyCounterOpnd = IR::MemRefOpnd::New((BYTE*)(header) + Js::LoopHeader::GetOffsetOfProfiledLoopCounter(), TyUint32, this->m_func);
     instr->SetDst(loopBodyCounterOpnd);
     instr->ReplaceSrc1(instr->GetSrc1()->AsRegOpnd()->UseWithNewType(TyUint32, this->m_func));
-    IR::AutoReuseOpnd(loopBodyCounterOpnd, this->m_func);
+    IR::AutoReuseOpnd autoReuse(loopBodyCounterOpnd, this->m_func);
     m_lowererMD.ChangeToAssign(instr);
     return;
 }
@@ -21156,8 +21156,12 @@ Lowerer::GenerateArgOutForStackArgs(IR::Instr* callInstr, IR::Instr* stackArgsIn
 
 
 #if defined(_M_IX86)
-     Assert(false);
-#endif
+    // We get a compilation error on x86 due to assigning a negative to a uint
+    // TODO: don't even define this function on x86 - we Assert(false) anyway there.
+    // Alternatively, don't define when INT_ARG_REG_COUNT - 4 < 0
+    AssertOrFailFast(false);
+    return nullptr;
+#else
 
     Assert(stackArgsInstr->m_opcode == Js::OpCode::ArgOut_A_FromStackArgs);
     Assert(callInstr->m_opcode == Js::OpCode::CallIDynamic);
@@ -21225,14 +21229,7 @@ Lowerer::GenerateArgOutForStackArgs(IR::Instr* callInstr, IR::Instr* stackArgsIn
 
     // 4 to denote this is 4th register after this, callinfo & function object
     // INT_ARG_REG_COUNT is the number of parameters passed in int regs
-    uint current_reg_pass =
-#if defined(_M_IX86)
-        // We get a compilation error on x86 due to assiging a negative to a uint
-        // TODO: don't even define this function on x86 - we Assert(false) anyway there.
-        0;
-#else
-        INT_ARG_REG_COUNT - 4;
-#endif
+    uint current_reg_pass = INT_ARG_REG_COUNT - 4;
 
     do
     {
@@ -21278,6 +21275,7 @@ Lowerer::GenerateArgOutForStackArgs(IR::Instr* callInstr, IR::Instr* stackArgsIn
 
     /*return the length which will be used for callInfo generations & stack allocation*/
     return saveLenInstr->GetDst()->AsRegOpnd();
+#endif
 }
 
 void

+ 1 - 0
lib/Common/Codex/Utf8Codex.cpp

@@ -17,6 +17,7 @@
 #pragma warning(push)
 
 #pragma warning(disable: 4127)  // constant expression for template parameter
+#pragma warning(disable: 26451) // size-conversion/arithmetic-operation ordering
 #endif
 
 namespace utf8

+ 32 - 22
lib/Common/Core/CriticalSection.h

@@ -4,6 +4,10 @@
 //-------------------------------------------------------------------------------------------------------
 #pragma once
 
+#ifdef _WIN32
+#include <suppress.h>
+#endif
+
 class CriticalSection
 #ifndef _WIN32
 : public CCLock
@@ -20,9 +24,9 @@ public:
         ::InitializeCriticalSectionAndSpinCount(&cs, spincount);
     }
     ~CriticalSection() { ::DeleteCriticalSection(&cs); }
-    BOOL TryEnter() { return ::TryEnterCriticalSection(&cs); }
-    void Enter() { ::EnterCriticalSection(&cs); }
-    void Leave() { ::LeaveCriticalSection(&cs); }
+    _Success_(return) BOOL _Acquires_lock_(this->cs) TryEnter() { return ::TryEnterCriticalSection(&cs); }
+    void _Acquires_lock_(this->cs) Enter() { ::EnterCriticalSection(&cs); }
+    void _Releases_lock_(this->cs) Leave() { ::LeaveCriticalSection(&cs); }
 #if DBG
     bool IsLocked() const { return cs.OwningThread == (HANDLE)::GetCurrentThreadId(); }
 #endif
@@ -37,19 +41,25 @@ class FakeCriticalSection
 public:
     FakeCriticalSection(DWORD spincount = 0) { /*do nothing*/spincount++; }
     ~FakeCriticalSection() {}
-    BOOL TryEnter() { return true; }
-    void Enter() {}
-    void Leave() {}
+#pragma prefast(suppress:__WARNING_FAILING_TO_ACQUIRE_MEDIUM_CONFIDENCE)
+    _Success_(return) BOOL _Acquires_lock_(this->cs) TryEnter() { return true; }
+#pragma prefast(suppress:__WARNING_FAILING_TO_ACQUIRE_MEDIUM_CONFIDENCE)
+    _Acquires_lock_(this->cs) void Enter() {}
+#pragma prefast(suppress:__WARNING_FAILING_TO_RELEASE_MEDIUM_CONFIDENCE)
+    _Releases_lock_(this->cs) void Leave() {}
 #if DBG
     bool IsLocked() const { return true; }
 #endif
+private:
+    // only used for prefast analysis
+    int cs;
 };
 
 class AutoCriticalSection
 {
 public:
-    AutoCriticalSection(CriticalSection * cs) : cs(cs) { cs->Enter(); }
-    ~AutoCriticalSection() { cs->Leave(); }
+    _Acquires_lock_(this->cs->cs) AutoCriticalSection(CriticalSection * cs) : cs(cs) { this->cs->Enter(); }
+    _Releases_lock_(this->cs->cs) ~AutoCriticalSection() { cs->Leave(); }
 private:
     CriticalSection * cs;
 };
@@ -57,19 +67,19 @@ private:
 class AutoOptionalCriticalSection
 {
 public:
-    AutoOptionalCriticalSection(CriticalSection * cs) : cs(cs)
+    _When_(this->cs != nullptr, _Acquires_lock_(this->cs->cs)) AutoOptionalCriticalSection(CriticalSection * cs) : cs(cs)
     {
-        if (cs)
+        if (this->cs)
         {
-            cs->Enter();
+            this->cs->Enter();
         }
     }
 
-    ~AutoOptionalCriticalSection()
+    _When_(this->cs != nullptr, _Releases_lock_(this->cs->cs)) ~AutoOptionalCriticalSection()
     {
-        if (cs)
+        if (this->cs)
         {
-            cs->Leave();
+            this->cs->Leave();
         }
     }
 
@@ -81,8 +91,8 @@ template <class SyncObject = FakeCriticalSection >
 class AutoRealOrFakeCriticalSection
 {
 public:
-    AutoRealOrFakeCriticalSection(SyncObject * cs) : cs(cs) { cs->Enter(); }
-    ~AutoRealOrFakeCriticalSection() { cs->Leave(); }
+    _Acquires_lock_(this->cs->cs) AutoRealOrFakeCriticalSection(SyncObject * cs) : cs(cs) { this->cs->Enter(); }
+    _Releases_lock_(this->cs->cs) ~AutoRealOrFakeCriticalSection() { this->cs->Leave(); }
 private:
     SyncObject * cs;
 };
@@ -91,19 +101,19 @@ template <class SyncObject = FakeCriticalSection >
 class AutoOptionalRealOrFakeCriticalSection
 {
 public:
-    AutoOptionalRealOrFakeCriticalSection(SyncObject * cs) : cs(cs)
+    _When_(this->cs != nullptr, _Acquires_lock_(this->cs->cs)) AutoOptionalRealOrFakeCriticalSection(SyncObject * cs) : cs(cs)
     {
-        if (cs)
+        if (this->cs)
         {
-            cs->Enter();
+            this->cs->Enter();
         }
     }
 
-    ~AutoOptionalRealOrFakeCriticalSection()
+    _When_(this->cs != nullptr, _Releases_lock_(this->cs->cs)) ~AutoOptionalRealOrFakeCriticalSection()
     {
-        if (cs)
+        if (this->cs)
         {
-            cs->Leave();
+            this->cs->Leave();
         }
     }
 

+ 6 - 0
lib/Common/Core/EtwTraceCore.h

@@ -74,12 +74,18 @@ CompileAssert(false)
 #define MCGEN_PRIVATE_ENABLE_CALLBACK_V2(SourceId, ControlCode, Level, MatchAnyKeyword, MatchAllKeyword, FilterData, CallbackContext) \
        EtwCallback(ControlCode, CallbackContext)
 
+// Work-around for a bug in the instrumentationevents generator
+#pragma prefast(push)
+#pragma prefast(disable:__WARNING_USING_UNINIT_VAR, "The ETW data generated from the manifest includes a default null function which uses unintialized memory.")
+
 #include <microsoft-scripting-chakra-instrumentationevents.h>
 #ifdef NTBUILD
 #include <ieresp_mshtml.h>
 #include <microsoft-scripting-jscript9.internalevents.h>
 #endif
 
+#pragma prefast(pop)
+
 //
 // Encapsulates base routines to initialize ETW tracing in the module
 //

+ 23 - 12
lib/Common/DataStructures/BaseDictionary.h

@@ -44,20 +44,29 @@ namespace JsDiag
 
 namespace JsUtil
 {
+    struct contentStruct
+    {
+        Field(int) cs;
+    };
     class NoResizeLock
     {
     public:
-        void BeginResize() {}
-        void EndResize() {}
+#pragma prefast(suppress:__WARNING_FAILING_TO_ACQUIRE_MEDIUM_CONFIDENCE)
+        void _Acquires_lock_(cs.cs) BeginResize() {}
+#pragma prefast(suppress:__WARNING_FAILING_TO_RELEASE_MEDIUM_CONFIDENCE)
+        void _Releases_lock_(cs.cs) EndResize() {}
+    private:
+        // For prefast analysis, we need to have a somewhat similar shape for both locks
+        Field(contentStruct) cs;
     };
 
     class AsymetricResizeLock
     {
     public:
-        void BeginResize() { cs.Enter(); }
-        void EndResize() { cs.Leave(); }
-        void LockResize() { cs.Enter(); }
-        void UnlockResize() { cs.Leave(); }
+        void _Acquires_lock_(cs.cs) BeginResize() { cs.Enter(); }
+        void _Releases_lock_(cs.cs) EndResize() { cs.Leave(); }
+        void _Acquires_lock_(cs.cs) LockResize() { cs.Enter(); }
+        void _Releases_lock_(cs.cs) UnlockResize() { cs.Leave(); }
     private:
         CriticalSection cs;
     };
@@ -117,8 +126,10 @@ namespace JsUtil
         class AutoDoResize
         {
         public:
-            AutoDoResize(Lock& lock) : lock(lock) { lock.BeginResize(); };
-            ~AutoDoResize() { lock.EndResize(); };
+#pragma prefast(suppress:__WARNING_FAILING_TO_ACQUIRE_MEDIUM_CONFIDENCE)
+            _Acquires_lock_(this->lock.cs.cs) AutoDoResize(Lock& lock) : lock(lock) { this->lock.BeginResize(); };
+#pragma prefast(suppress:__WARNING_CALLER_FAILING_TO_HOLD_MEDIUM_CONFIDENCE)
+            _Releases_lock_(this->lock.cs.cs) ~AutoDoResize() { this->lock.EndResize(); };
         private:
             Lock& lock;
         };
@@ -671,12 +682,12 @@ namespace JsUtil
             DoCopy(other);
         }
 
-        void LockResize()
+        void _Acquires_lock_(this->cs.cs) LockResize()
         {
             __super::LockResize();
         }
 
-        void UnlockResize()
+        void _Releases_lock_(this->cs.cs) UnlockResize()
         {
             __super::UnlockResize();
         }
@@ -1573,12 +1584,12 @@ namespace JsUtil
             this->DoCopy(other);
         }
 
-        void LockResize()
+        void _Acquires_lock_(this->cs.cs) LockResize()
         {
             __super::LockResize();
         }
 
-        void UnlockResize()
+        void _Releases_lock_(this->cs.cs) UnlockResize()
         {
             __super::UnlockResize();
         }

+ 4 - 1
lib/Common/Memory/LargeHeapBlock.cpp

@@ -389,7 +389,10 @@ LargeHeapBlock::ReleasePages(Recycler * recycler)
 #endif
 
 #ifdef RECYCLER_FREE_MEM_FILL
-    memset(blockStartAddress, DbgMemFill, AutoSystemInfo::PageSize * realPageCount);
+    if(blockStartAddress != nullptr)
+    {
+        memset(blockStartAddress, DbgMemFill, AutoSystemInfo::PageSize * realPageCount);
+    }
 #endif
     pageAllocator->Release(blockStartAddress, realPageCount, segment);
     RECYCLER_PERF_COUNTER_SUB(LargeHeapBlockPageSize, pageCount * AutoSystemInfo::PageSize);

+ 1 - 0
lib/Common/Memory/LeakReport.cpp

@@ -19,6 +19,7 @@
 //  AU RecyclerWriteBarrierManager
 #pragma warning(disable:4075)       // initializers put in unrecognized initialization area on purpose
 #pragma init_seg(".CRT$XCAR")
+#pragma prefast(disable:__WARNING_CALLER_FAILING_TO_HOLD, "Not annotating this file for lock semantics due to poor accuracy and complicated conditions for some locks")
 
 CriticalSection LeakReport::s_cs;
 DWORD LeakReport::nestedSectionCount = 0;

+ 1 - 0
lib/Common/Memory/MarkContext.cpp

@@ -83,6 +83,7 @@ void MarkContext::Release()
 
 uint MarkContext::Split(uint targetCount, __in_ecount(targetCount) MarkContext ** targetContexts)
 {
+#pragma prefast(suppress:__WARNING_REDUNDANTTEST, "Due to implementation of the PageStack template this test may end up being redundant")
     Assert(targetCount > 0 && targetCount <= PageStack<MarkCandidate>::MaxSplitTargets && targetCount <= PageStack<IRecyclerVisitedObject*>::MaxSplitTargets);
     __analysis_assume(targetCount <= PageStack<MarkCandidate>::MaxSplitTargets);
     __analysis_assume(targetCount <= PageStack<IRecyclerVisitedObject*>::MaxSplitTargets);

+ 6 - 5
lib/Common/PlatformAgnostic/DateTimeInternal.h

@@ -61,7 +61,7 @@ namespace DateTime
         uint32 lastTimeZoneUpdateTickCount;
 
         void UpdateTimeZoneInfo();
-        UtilityPlatformData(): lastTimeZoneUpdateTickCount(0) { }
+        UtilityPlatformData() : lastTimeZoneUpdateTickCount(0) { GetTimeZoneInformation(&timeZoneInfo); }
     };
 
     class HiresTimerPlatformData
@@ -78,13 +78,14 @@ namespace DateTime
         bool fHiResAvailable;
 
         HiresTimerPlatformData() :
-            fInit(false),
             dBaseTime(0),
-            baseMsCount(0),
-            fHiResAvailable(true),
             dLastTime(0),
             dAdjustFactor(1),
-            fReset(true)
+            baseMsCount(0),
+            freq(0),
+            fReset(true),
+            fInit(false),
+            fHiResAvailable(true)
         {
         }
 

+ 11 - 0
lib/Common/Warnings.h

@@ -38,17 +38,28 @@
 #pragma warning(disable:28112)      // A variable (processNativeCodeSize) which is accessed via an Interlocked function must always be accessed via an Interlocked function. See line 1024:  It is not always safe to access a variable which is accessed via the Interlocked* family of functions in any other way.
 #pragma warning(disable:28159)      // Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days.  Code that does not take that into account can loop indefinitely.  GetTickCount64 operates on 64 bit values and does not have that problem
 
+#pragma warning(disable:6011)       // potentially dereferencing null pointer
 #pragma warning(disable:6235)       // Logical OR with non-zero constant on the left: 1 || <expr>
 #pragma warning(disable:6236)       // Logical-OR with non-zero constant, e.g., <expr> || 1.  We end up with a lot of these in release builds because certain macros (notably CONFIG_FLAG) expand to compile-time constants in release builds and not in debug builds.
 #pragma warning(disable:6327)       // False constant expr on left side of AND, so right side never evaluated for effects -- e.g., 0 && <expr>
 #pragma warning(disable:6239)       // NONZEROLOGICALAND:  1 && <expr> ?
 #pragma warning(disable:6240)       // LOGICALANDNONZERO:  <expr> && 1 ?
+#pragma warning(disable:6271)       // extra argument provided beyond format string - typically due to macro issues
+#pragma warning(disable:6323)       // use of arithmetic operator on boolean types
+#pragma warning(disable:6340)       // sign mismatch on printf format string
+#pragma warning(disable:6387)       // argument to system library function could be null, which is technically UB but generally just an AV (or harmless)
 #pragma warning(disable:25037)      // True constant expr in AND, e.g., <expr> && 1.
 #pragma warning(disable:25038)      // False constant expr in AND, e.g., <expr> && 0.
 #pragma warning(disable:25039)      // True Constant Expr in OR.  Seems to be a duplicate of 6236.
 #pragma warning(disable:25040)      // False Constant Expr in OR, e.g., <expr> || 0.
 #pragma warning(disable:25041)      // 'if' condition is always true
 #pragma warning(disable:25042)      // 'if' condition is always false
+#pragma warning(disable:26434)      // function definition hides a non-virtual function
+#pragma warning(disable:26437)      // avoid slicing - this is more of a guideline than a rule, and we don't do it often regardless
+#pragma warning(disable:26439)      // noexcept specifier implied
+#pragma warning(disable:26451)      // doing math on smaller types than possible
+#pragma warning(disable:26454)      // arithmetic overflow at compile time (due to us doing "0 - 1" intentionally)
+#pragma warning(disable:26495)      // member not initialized (generally due to our heavy use of out-of-thread-zeroing allocators)
 
 #ifndef NTBUILD
 // Would be nice to clean these up.

+ 4 - 0
lib/JITClient/JITManager.cpp

@@ -223,6 +223,9 @@ JITManager::IsOOPJITEnabled() const
     return m_oopJitEnabled;
 }
 
+#pragma prefast(push)
+#pragma prefast(disable:__WARNING_RELEASING_UNHELD_LOCK_MEDIUM_CONFIDENCE, "Lock is correctly acquired and released by RAII class AutoCriticalSection")
+#pragma prefast(disable:__WARNING_CALLER_FAILING_TO_HOLD, "Lock is correctly acquired and released by RAII class AutoCriticalSection")
 HRESULT
 JITManager::ConnectRpcServer(__in HANDLE jitProcessHandle, __in_opt void* serverSecurityDescriptor, __in UUID connectionUuid)
 {
@@ -260,6 +263,7 @@ FailureCleanup:
 
     return hr;
 }
+#pragma prefast(pop)
 
 HRESULT
 JITManager::Shutdown()

+ 1 - 1
lib/JITServer/JITServer.cpp

@@ -559,7 +559,7 @@ ServerNewInterpreterThunkBlock(
 HRESULT
 ServerIsInterpreterThunkAddr(
     /* [in] */ handle_t binding,
-    /* [in] */ PSCRIPTCONTEXT_HANDLE scriptContextInfoAddress,
+    /* [in] */ __RPC__in PSCRIPTCONTEXT_HANDLE scriptContextInfoAddress,
     /* [in] */ intptr_t address,
     /* [in] */ boolean asmjsThunk,
     /* [out] */ __RPC__out boolean * result)

+ 2 - 2
lib/Runtime/Base/CrossSiteObject.h

@@ -15,7 +15,7 @@ namespace Js
     public:
         virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, JavascriptString* propertyNameString, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
-        virtual BOOL GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext * requestContext) override;
         virtual PropertyQueryFlags GetPropertyReferenceQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
         virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
@@ -75,7 +75,7 @@ namespace Js
     }
 
     template <typename T>
-    BOOL CrossSiteObject<T>::GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL CrossSiteObject<T>::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext * requestContext)
     {
         BOOL result = __super::GetAccessors(propertyId, getter, setter, requestContext);
         if (result)

+ 2 - 2
lib/Runtime/Base/FunctionBody.cpp

@@ -1170,7 +1170,7 @@ namespace Js
     FunctionBody::SetOutParamMaxDepth(RegSlot cOutParamsDepth)
     {
 #if _M_X64
-        const RegSlot minAsmJsOutParams = MinAsmJsOutParams();
+        constexpr RegSlot minAsmJsOutParams = MinAsmJsOutParams();
         if (GetIsAsmJsFunction() && cOutParamsDepth < minAsmJsOutParams)
         {
             cOutParamsDepth = minAsmJsOutParams;
@@ -9600,4 +9600,4 @@ namespace Js
 // Don't grow these data structure unless absolutely necessary
 CompileAssert(sizeof(Js::EntryPointInfo) <= 56);
 CompileAssert(sizeof(Js::FunctionEntryPointInfo) <= 96);
-#endif
+#endif

+ 1 - 0
lib/Runtime/Base/FunctionExecutionStateMachine.cpp

@@ -4,6 +4,7 @@
 //-------------------------------------------------------------------------------------------------------
 #include "RuntimeBasePch.h"
 #include "FunctionExecutionStateMachine.h"
+#include "Warnings.h"
 
 namespace Js
 {

+ 1 - 1
lib/Runtime/Debug/TTInflateMap.cpp

@@ -300,7 +300,7 @@ namespace TTD
         ;
     }
 
-    void TTDComparePath::WritePathToConsole(ThreadContext* threadContext, bool printNewline, _Out_writes_z_(buffLength) char16* namebuff, charcount_t namebuffLength) const
+    void TTDComparePath::WritePathToConsole(ThreadContext* threadContext, bool printNewline, _Out_writes_z_(namebuffLength) char16* namebuff, charcount_t namebuffLength) const
     {
         if(this->m_prefix != nullptr)
         {

+ 2 - 1
lib/Runtime/Language/JavascriptOperators.cpp

@@ -2681,7 +2681,7 @@ CommonNumber:
         return FALSE;
     }
 
-    BOOL JavascriptOperators::GetAccessors(RecyclableObject* instance, PropertyId propertyId, ScriptContext* requestContext, Var* getter, Var* setter)
+    BOOL _Check_return_ _Success_(return) JavascriptOperators::GetAccessors(RecyclableObject* instance, PropertyId propertyId, ScriptContext* requestContext, _Out_ Var* getter, _Out_ Var* setter)
     {
         RecyclableObject* object = instance;
         while (!JavascriptOperators::IsNull(object))
@@ -8851,6 +8851,7 @@ SetElementIHelper_INDEX_TYPE_IS_NUMBER:
                 if (!descriptor.GetterSpecified() || !descriptor.SetterSpecified())
                 {
                     // Unless both getter and setter are specified, make sure we don't overwrite old accessor.
+#pragma prefast(suppress:6031, "We defaulted oldGetter and oldSetter already, so ignoring the return value here is safe")
                     obj->GetAccessors(propId, &oldGetter, &oldSetter, scriptContext);
                 }
 

+ 1 - 1
lib/Runtime/Language/JavascriptOperators.h

@@ -223,7 +223,7 @@ namespace Js
         static BOOL SetProperty(Var instance, RecyclableObject* object, PropertyId propertyId, Var newValue, ScriptContext* requestContext, PropertyOperationFlags flags = PropertyOperation_None);
         static BOOL SetProperty(Var instance, RecyclableObject* receiver, PropertyId propertyId, Var newValue, PropertyValueInfo * info, ScriptContext* requestContext, PropertyOperationFlags flags = PropertyOperation_None);
         static BOOL SetRootProperty(RecyclableObject* instance, PropertyId propertyId, Var newValue, PropertyValueInfo * info, ScriptContext* requestContext, PropertyOperationFlags flags = PropertyOperation_None);
-        static BOOL GetAccessors(RecyclableObject* instance, PropertyId propertyId, ScriptContext* requestContext, Var* getter, Var* setter);
+        static _Check_return_ _Success_(return) BOOL GetAccessors(RecyclableObject* instance, PropertyId propertyId, ScriptContext* requestContext, _Out_ Var* getter, _Out_ Var* setter);
         static BOOL SetAccessors(RecyclableObject* instance, PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None);
         static BOOL InitProperty(RecyclableObject* instance, PropertyId propertyId, Var newValue, PropertyOperationFlags flags = PropertyOperation_None);
         static BOOL DeleteProperty(RecyclableObject* instance, PropertyId propertyId, PropertyOperationFlags propertyOperationFlags = PropertyOperation_None);

+ 1 - 1
lib/Runtime/Language/ModuleNamespace.h

@@ -61,7 +61,7 @@ namespace Js
         virtual BOOL DeleteItem(uint32 index, PropertyOperationFlags flags) override { return true; }
         virtual BOOL GetEnumerator(JavascriptStaticEnumerator * enumerator, EnumeratorFlags flags, ScriptContext* requestContext, EnumeratorCache * enumeratorCache = nullptr);
         virtual BOOL SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) override { return false; }
-        virtual BOOL GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext) override { return false; }
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext) override { return FALSE; };
         virtual BOOL IsWritable(PropertyId propertyId) override;
         virtual BOOL IsConfigurable(PropertyId propertyId) override;
         virtual BOOL IsEnumerable(PropertyId propertyId) override;

+ 1 - 1
lib/Runtime/Language/SimdBool32x4OperationX86X64.cpp

@@ -11,7 +11,7 @@ namespace Js
     SIMDValue SIMDBool32x4Operation::OpBool32x4(bool x, bool y, bool z, bool w)
     {
         X86SIMDValue x86Result;
-        x86Result.m128i_value = _mm_set_epi32(w * -1, z * -1, y * -1, x * -1);
+        x86Result.m128i_value = _mm_set_epi32(w?-1:0, z?-1:0, y?-1:0, x?-1:0);
         return X86SIMDValue::ToSIMDValue(x86Result);
     }
 

+ 1 - 0
lib/Runtime/Library/AtomicsObject.cpp

@@ -220,6 +220,7 @@ namespace Js
 
             DWORD_PTR agent = (DWORD_PTR)scriptContext;
             Assert(sharedArrayBuffer->GetSharedContents()->IsValidAgent(agent));
+#pragma prefast(suppress:__WARNING_CALLER_FAILING_TO_HOLD, "This is a prefast false-positive caused by it being unable to identify that the critical section used here is the same as the one held by the AutoCriticalSection")
             awoken = waiterList->AddAndSuspendWaiter(agent, timeout);
             if (!awoken) 
             {

+ 1 - 1
lib/Runtime/Library/BoundFunction.cpp

@@ -409,7 +409,7 @@ namespace Js
         return false;
     }
 
-    BOOL BoundFunction::GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL BoundFunction::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext)
     {
         return DynamicObject::GetAccessors(propertyId, getter, setter, requestContext);
     }

+ 1 - 1
lib/Runtime/Library/BoundFunction.h

@@ -33,7 +33,7 @@ namespace Js
         virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
         virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
 
-        virtual BOOL GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext) override;
         virtual DescriptorFlags GetSetter(PropertyId propertyId, Var *setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual DescriptorFlags GetSetter(JavascriptString* propertyNameString, Var *setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
 

+ 1 - 1
lib/Runtime/Library/GlobalObject.cpp

@@ -1855,7 +1855,7 @@ LHexError:
             (this->hostObject && JavascriptOperators::GetProperty(this->hostObject, propertyId, value, requestContext, info));
     }
 
-    BOOL GlobalObject::GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL GlobalObject::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext)
     {
         if (DynamicObject::GetAccessors(propertyId, getter, setter, requestContext))
         {

+ 1 - 1
lib/Runtime/Library/GlobalObject.h

@@ -152,7 +152,7 @@ namespace Js
         virtual PropertyQueryFlags GetItemReferenceQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
         virtual PropertyQueryFlags GetItemQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
         virtual DescriptorFlags GetItemSetter(uint32 index, Var* setterValue, ScriptContext* requestContext) override;
-        virtual BOOL GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext) override;
         virtual BOOL SetItem(uint32 index, Var value, PropertyOperationFlags flags) override;
         virtual BOOL DeleteItem(uint32 index, PropertyOperationFlags flags) override;
         virtual BOOL SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags) override;

+ 1 - 1
lib/Runtime/Library/JavascriptFunction.cpp

@@ -2506,7 +2506,7 @@ LABEL1:
         return DynamicObject::HasPropertyQuery(propertyId, info);
     }
 
-    BOOL JavascriptFunction::GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL JavascriptFunction::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext)
     {
         Assert(!this->IsBoundFunction());
         Assert(propertyId != Constants::NoProperty);

+ 1 - 1
lib/Runtime/Library/JavascriptFunction.h

@@ -199,7 +199,7 @@ namespace Js
         virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
         virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
         virtual BOOL SetPropertyWithAttributes(PropertyId propertyId, Var value, PropertyAttributes attributes, PropertyValueInfo* info, PropertyOperationFlags flags = PropertyOperation_None, SideEffects possibleSideEffects = SideEffects_Any) override;
-        virtual BOOL GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext) override;
         virtual DescriptorFlags GetSetter(PropertyId propertyId, Var *setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual DescriptorFlags GetSetter(JavascriptString* propertyNameString, Var *setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual BOOL IsConfigurable(PropertyId propertyId) override;

+ 1 - 1
lib/Runtime/Library/JavascriptGeneratorFunction.cpp

@@ -421,7 +421,7 @@ using namespace Js;
         return JavascriptFunction::SetAccessors(propertyId, getter, setter, flags);
     }
 
-    BOOL JavascriptGeneratorFunction::GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL JavascriptGeneratorFunction::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext)
     {
         if (propertyId == PropertyIds::length)
         {

+ 1 - 1
lib/Runtime/Library/JavascriptGeneratorFunction.h

@@ -66,7 +66,7 @@ namespace Js
         virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
 
         virtual BOOL SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) override;
-        virtual BOOL GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext) override;
         virtual DescriptorFlags GetSetter(PropertyId propertyId, Var *setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual DescriptorFlags GetSetter(JavascriptString* propertyNameString, Var *setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
 

+ 10 - 3
lib/Runtime/Library/JavascriptProxy.cpp

@@ -591,7 +591,7 @@ namespace Js
         return FALSE;
     }
   
-    BOOL JavascriptProxy::GetAccessors(PropertyId propertyId, __out Var* getter, __out Var* setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL JavascriptProxy::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext)
     {
         PropertyDescriptor result;
         if (getter != nullptr)
@@ -2145,6 +2145,7 @@ namespace Js
                     ::Math::DefaultOverflowPolicy();
                 }
             }
+            AnalysisAssert(newCount >= (ushort)args.Info.Count);
 
             Var* newValues;
             const unsigned STACK_ARGS_ALLOCA_THRESHOLD = 8; // Number of stack args we allow before using _alloca
@@ -2165,13 +2166,19 @@ namespace Js
                 calleeInfo.Flags = (CallFlags)(calleeInfo.Flags | CallFlags_ExtraArg | CallFlags_NewTarget);
             }
 
-            for (uint argCount = 0; argCount < args.Info.Count; argCount++)
+            for (ushort argCount = 0; argCount < (ushort)args.Info.Count; argCount++)
             {
+                AnalysisAssert(newCount >= ((ushort)args.Info.Count));
+                AnalysisAssert(argCount < newCount);
+                AnalysisAssert(argCount < (ushort)args.Info.Count);
+                AnalysisAssert(sizeof(Var*) == sizeof(void*));
+                AnalysisAssert(sizeof(Var*) * argCount < sizeof(void*) * newCount);
+#pragma prefast(suppress:__WARNING_WRITE_OVERRUN, "This is a false positive, and all of the above analysis asserts still didn't convince prefast of that.")
                 newValues[argCount] = args.Values[argCount];
             }
-#pragma prefast(suppress:6386)
             if (isNewCall)
             {
+                AnalysisAssert(newCount == ((ushort)args.Info.Count) + 1);
                 newValues[args.Info.Count] = newTarget;
             }
 

+ 1 - 1
lib/Runtime/Library/JavascriptProxy.h

@@ -83,7 +83,7 @@ namespace Js
         virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, JavascriptString* propertyNameString, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual BOOL GetInternalProperty(Var instance, PropertyId internalPropertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
-        virtual BOOL GetAccessors(PropertyId propertyId, __out Var* getter, __out Var* setter, ScriptContext * requestContext) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext) override;
         virtual PropertyQueryFlags GetPropertyReferenceQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
         virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;

+ 1 - 1
lib/Runtime/Library/ModuleRoot.cpp

@@ -130,7 +130,7 @@ namespace Js
         return ModuleRoot::GetPropertyQuery(originalInstance, propertyRecord->GetPropertyId(), value, info, requestContext);
     }
 
-    BOOL ModuleRoot::GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL ModuleRoot::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext)
     {
         if (DynamicObject::GetAccessors(propertyId, getter, setter, requestContext))
         {

+ 1 - 1
lib/Runtime/Library/ModuleRoot.h

@@ -26,7 +26,7 @@ namespace Js
         virtual BOOL UseDynamicObjectForNoHostObjectAccess() override { return TRUE; }
         virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, JavascriptString* propertyNameString, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
-        virtual BOOL GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext) override;
         virtual BOOL DeleteProperty(PropertyId propertyId, PropertyOperationFlags flags) override;
         virtual BOOL DeleteProperty(JavascriptString *propertyNameString, PropertyOperationFlags flags) override;
         virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;

+ 1 - 1
lib/Runtime/Library/SharedArrayBuffer.cpp

@@ -722,7 +722,7 @@ namespace Js
         return false;
     }
 
-    bool WaiterList::AddAndSuspendWaiter(DWORD_PTR waiter, uint32 timeout)
+    bool _Requires_lock_held_(csForAccess.cs) WaiterList::AddAndSuspendWaiter(DWORD_PTR waiter, uint32 timeout)
     {
 #ifdef _WIN32
         Assert(m_waiters != nullptr);

+ 2 - 2
lib/Runtime/Library/SharedArrayBuffer.h

@@ -182,7 +182,7 @@ namespace Js
         WaiterList();
         void Cleanup();
 
-        bool AddAndSuspendWaiter(DWORD_PTR waiter, uint32 timeout);
+        bool _Requires_lock_held_(csForAccess.cs) AddAndSuspendWaiter(DWORD_PTR waiter, uint32 timeout);
         void RemoveWaiter(DWORD_PTR waiter);
         uint32 RemoveAndWakeWaiters(int32 count);
 
@@ -194,7 +194,7 @@ namespace Js
 
         Waiters * m_waiters;
 
-        // Below CS is used for synchronizig access in wait/wake API
+        // Below CS is used for synchronizing access in wait/wake API
         CriticalSection csForAccess;
     };
 }

+ 3 - 0
lib/Runtime/Math/AsmJsMath.cpp

@@ -12,6 +12,8 @@ namespace Js
 #else
 #define DB_NOINLINE
 #endif
+#pragma prefast(push)
+#pragma prefast(disable:26450) // PREfast takes issue with how INT_MIN is defined
 
     // Double
     template<> DB_NOINLINE double AsmJsMath::DivChecked<double>(double aLeft, double aRight) { return aLeft / aRight; }
@@ -93,3 +95,4 @@ namespace Js
     }
     template<> bool AsmJsMath::RemWouldTrap(uint64 aLeft, uint64 aRight) { return aRight == 0 || (aLeft == LONGLONG_MIN && aRight == -1); }
 }
+#pragma prefast(pop

+ 2 - 2
lib/Runtime/Types/DeferredTypeHandler.h

@@ -122,7 +122,7 @@ namespace Js
         virtual BOOL SetWritable(DynamicObject* instance, PropertyId propertyId, BOOL value) override;
         virtual BOOL SetConfigurable(DynamicObject* instance, PropertyId propertyId, BOOL value) override;
         virtual BOOL SetAccessors(DynamicObject* instance, PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) override;
-        virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, __out Var *getter, __out Var *setter) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter) override;
         virtual BOOL PreventExtensions(DynamicObject *instance) override;
         virtual BOOL Seal(DynamicObject *instance) override;
         virtual BOOL SetPropertyWithAttributes(DynamicObject* instance, PropertyId propertyId, Var value, PropertyAttributes attributes, PropertyValueInfo* info, PropertyOperationFlags flags = PropertyOperation_None, SideEffects possibleSideEffects = SideEffects_Any) override;
@@ -560,7 +560,7 @@ namespace Js
     }
 
     template <DeferredTypeInitializer initializer, typename DeferredTypeFilter, bool isPrototypeTemplate, uint16 _inlineSlotCapacity, uint16 _offsetOfInlineSlots>
-    BOOL DeferredTypeHandler<initializer, DeferredTypeFilter, isPrototypeTemplate, _inlineSlotCapacity, _offsetOfInlineSlots>::GetAccessors(DynamicObject* instance, PropertyId propertyId, __out Var *getter, __out Var *setter)
+    _Check_return_ _Success_(return) BOOL DeferredTypeHandler<initializer, DeferredTypeFilter, isPrototypeTemplate, _inlineSlotCapacity, _offsetOfInlineSlots>::GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter)
     {
         if (getter != nullptr)
         {

+ 6 - 1
lib/Runtime/Types/DictionaryTypeHandler.cpp

@@ -1548,7 +1548,7 @@ namespace Js
     }
 
     template <typename T>
-    BOOL DictionaryTypeHandlerBase<T>::GetAccessors(DynamicObject* instance, PropertyId propertyId, Var* getter, Var* setter)
+    _Check_return_ _Success_(return) BOOL DictionaryTypeHandlerBase<T>::GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter)
     {
         DictionaryPropertyDescriptor<T>* descriptor;
         ScriptContext* scriptContext = instance->GetScriptContext();
@@ -1569,11 +1569,16 @@ namespace Js
                 if (descriptor->GetGetterPropertyIndex() != NoSlots)
                 {
                     *getter = instance->GetSlot(descriptor->GetGetterPropertyIndex());
+                    *setter = nullptr;
                     getset = true;
                 }
                 if (descriptor->GetSetterPropertyIndex() != NoSlots)
                 {
                     *setter = instance->GetSlot(descriptor->GetSetterPropertyIndex());
+                    if(!getset) {
+                        // if we didn't set the getter above, we need to set it here
+                        *getter = nullptr;
+                    }
                     getset = true;
                 }
                 return getset;

+ 1 - 1
lib/Runtime/Types/DictionaryTypeHandler.h

@@ -122,7 +122,7 @@ namespace Js
         virtual BOOL SetItemAccessors(DynamicObject* instance, uint32 index, Var getter, Var setter) override;
         virtual DescriptorFlags GetItemSetter(DynamicObject* instance, uint32 index, Var* setterValue, ScriptContext* requestContext) override;
         virtual BOOL SetAccessors(DynamicObject* instance, PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) override sealed;
-        virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, Var* getter, Var* setter) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter) override;
         virtual BOOL PreventExtensions(DynamicObject *instance) override;
         virtual BOOL Seal(DynamicObject* instance) override;
         virtual BOOL IsSealed(DynamicObject* instance) override;

+ 1 - 1
lib/Runtime/Types/DynamicObject.h

@@ -274,7 +274,7 @@ namespace Js
         virtual BOOL ToPrimitive(JavascriptHint hint, Var* result, ScriptContext * requestContext) override;
         virtual BOOL GetEnumerator(JavascriptStaticEnumerator * enumerator, EnumeratorFlags flags, ScriptContext * scriptContext, EnumeratorCache * enumeratorCache = nullptr) override;
         virtual BOOL SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) override;
-        virtual BOOL GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext) override;
         virtual BOOL IsWritable(PropertyId propertyId) override;
         virtual BOOL IsConfigurable(PropertyId propertyId) override;
         virtual BOOL IsEnumerable(PropertyId propertyId) override;

+ 1 - 1
lib/Runtime/Types/DynamicType.cpp

@@ -497,7 +497,7 @@ namespace Js
         return GetTypeHandler()->SetAccessors(this, propertyId, getter, setter, flags);
     }
 
-    BOOL DynamicObject::GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL DynamicObject::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext* requestContext)
     {
         return GetTypeHandler()->GetAccessors(this, propertyId, getter, setter);
     }

+ 1 - 1
lib/Runtime/Types/ES5ArrayTypeHandler.cpp

@@ -1152,7 +1152,7 @@ namespace Js
     }
 
     template <class T>
-    BOOL ES5ArrayTypeHandlerBase<T>::GetAccessors(DynamicObject* instance, PropertyId propertyId, Var* getter, Var* setter)
+    _Check_return_ _Success_(return) BOOL ES5ArrayTypeHandlerBase<T>::GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter)
     {
         ScriptContext* scriptContext = instance->GetScriptContext();
 

+ 1 - 1
lib/Runtime/Types/ES5ArrayTypeHandler.h

@@ -180,7 +180,7 @@ namespace Js
         virtual BOOL SetEnumerable(DynamicObject* instance, PropertyId propertyId, BOOL value) override;
         virtual BOOL SetWritable(DynamicObject* instance, PropertyId propertyId, BOOL value) override;
         virtual BOOL SetConfigurable(DynamicObject* instance, PropertyId propertyId, BOOL value) override;
-        virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, Var* getter, Var* setter) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter) override;
         virtual BOOL Seal(DynamicObject* instance) override;
         virtual BOOL IsSealed(DynamicObject* instance) override;
         virtual BOOL IsFrozen(DynamicObject* instance) override;

+ 1 - 1
lib/Runtime/Types/PathTypeHandler.cpp

@@ -3541,7 +3541,7 @@ namespace Js
         return SetAttributesHelper(instance, propertyId, propertyIndex, attributes, attr);
     }
 
-    BOOL PathTypeHandlerWithAttr::GetAccessors(DynamicObject* instance, PropertyId propertyId, Var* getter, Var* setter)
+    _Check_return_ _Success_(return) BOOL PathTypeHandlerWithAttr::GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter)
     {
         PropertyIndex propertyIndex = GetTypePath()->LookupInline(propertyId, GetPathLength());
         if (propertyIndex == Constants::NoSlot)

+ 1 - 1
lib/Runtime/Types/PathTypeHandler.h

@@ -515,7 +515,7 @@ namespace Js
         virtual BOOL SetProperty(DynamicObject* instance, PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
         virtual BOOL SetProperty(DynamicObject* instance, JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
 
-        virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, Var* getter, Var* setter) override;
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter) override;
         virtual BOOL SetAccessors(DynamicObject* instance, PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) override;
         virtual DescriptorFlags GetSetter(DynamicObject* instance, PropertyId propertyId, Var* setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
         virtual DescriptorFlags GetSetter(DynamicObject* instance, JavascriptString* propertyNameString, Var* setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;

+ 1 - 1
lib/Runtime/Types/RecyclableObject.cpp

@@ -482,7 +482,7 @@ namespace Js
         return false;
     }
 
-    BOOL RecyclableObject::GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext)
+    _Check_return_ _Success_(return) BOOL RecyclableObject::GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext * requestContext)
     {
         return false;
     }

+ 1 - 1
lib/Runtime/Types/RecyclableObject.h

@@ -304,7 +304,7 @@ namespace Js {
         virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext);
         virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, JavascriptString* propertyNameString, Var* value, PropertyValueInfo* info, ScriptContext* requestContext);
         virtual BOOL GetInternalProperty(Var instance, PropertyId internalPropertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext);
-        virtual BOOL GetAccessors(PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext);
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext * requestContext);
         virtual PropertyQueryFlags GetPropertyReferenceQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext);
         virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info);
         virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info);

+ 1 - 1
lib/Runtime/Types/SpreadArgument.h

@@ -56,7 +56,7 @@ namespace Js
         virtual BOOL ToPrimitive(JavascriptHint hint, Var* result, ScriptContext * requestContext) override { AssertAndFailFast(); return FALSE; };
         virtual BOOL GetEnumerator(JavascriptStaticEnumerator * enumerator, EnumeratorFlags flags, ScriptContext* requestContext, EnumeratorCache * enumeratorCache = nullptr) override { AssertAndFailFast(); return FALSE; };
         virtual BOOL SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) override { AssertAndFailFast(); return FALSE; };
-        virtual BOOL GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext) override { AssertAndFailFast(); return FALSE; };
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext * requestContext) override { AssertAndFailFast();  return FALSE; };
         virtual BOOL IsWritable(PropertyId propertyId) override { AssertAndFailFast(); return FALSE; };
         virtual BOOL IsConfigurable(PropertyId propertyId) override { AssertAndFailFast(); return FALSE; };
         virtual BOOL IsEnumerable(PropertyId propertyId) override { AssertAndFailFast(); return FALSE; };

+ 1 - 1
lib/Runtime/Types/TypeHandler.h

@@ -499,7 +499,7 @@ namespace Js
         virtual DescriptorFlags GetItemSetter(DynamicObject* instance, uint32 index, Var* setterValue, ScriptContext* requestContext);
 
         virtual BOOL SetAccessors(DynamicObject* instance, PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) = 0;
-        virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, Var* getter, Var* setter) { return false; };
+        _Check_return_ _Success_(return) virtual BOOL GetAccessors(DynamicObject* instance, PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter) { return FALSE; };
 
         virtual BOOL PreventExtensions(DynamicObject *instance) = 0;
         virtual BOOL Seal(DynamicObject *instance) = 0;

+ 1 - 1
lib/Runtime/Types/WithScopeObject.h

@@ -60,7 +60,7 @@ namespace Js
             virtual BOOL ToPrimitive(JavascriptHint hint, Var* result, ScriptContext * requestContext) override { UNWRAP_FAILFAST(); return FALSE; };
             virtual BOOL GetEnumerator(JavascriptStaticEnumerator * enumerator, EnumeratorFlags flags, ScriptContext* requestContext, EnumeratorCache * enumeratorCache = nullptr) override { UNWRAP_FAILFAST(); return FALSE; };
             virtual BOOL SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags = PropertyOperation_None) override { UNWRAP_FAILFAST(); return FALSE; };
-            virtual BOOL GetAccessors(PropertyId propertyId, Var *getter, Var *setter, ScriptContext * requestContext) override { UNWRAP_FAILFAST(); return FALSE; };
+            _Check_return_ _Success_(return) virtual BOOL GetAccessors(PropertyId propertyId, _Outptr_result_maybenull_ Var* getter, _Outptr_result_maybenull_ Var* setter, ScriptContext * requestContext) override { UNWRAP_FAILFAST(); return FALSE; };
             virtual BOOL IsWritable(PropertyId propertyId) override { UNWRAP_FAILFAST(); return FALSE; };
             virtual BOOL IsConfigurable(PropertyId propertyId) override { UNWRAP_FAILFAST(); return FALSE; };
             virtual BOOL IsEnumerable(PropertyId propertyId) override { UNWRAP_FAILFAST(); return FALSE; };

+ 1 - 0
lib/WasmReader/WasmBinaryReader.cpp

@@ -1279,6 +1279,7 @@ LEBType WasmBinaryReader::LEB128(uint32 &length)
 
     if (sign && (shift < (sizeof(LEBType) * 8)) && (0x40 & b))
     {
+#pragma prefast(suppress:26453)
         result |= ((~(LEBType)0) << shift);
     }
     return result;

+ 1 - 1
lib/wabt/src/color.cc

@@ -54,7 +54,7 @@ bool Color::SupportsColor(FILE* file) {
     }
     DWORD mode;
     if (!_isatty(_fileno(file)) || !GetConsoleMode(handle, &mode) ||
-        !SetConsoleMode(handle, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) {
+        !SetConsoleMode(handle, mode | 0x4)) { // ENABLE_VIRTUAL_TERMINAL_PROCESSING not defined in some kits on win7
       return false;
     }
     return true;