Skip to content

Commit d7e19fd

Browse files
committed
[MERGE #5468 @sethbrenith] Fix a few static analysis warnings
Merge pull request #5468 from sethbrenith:user/sethb/prefast-2 Fixes OS:18281928 Fixes OS:18281785 Fixes OS:18273031
2 parents 841036a + 6d6517e commit d7e19fd

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

lib/Common/Core/ConfigParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void ConfigParser::ParseRegistryKey(HKEY hk, CmdLineArgsParser &parser)
358358

359359
#ifdef _WIN32
360360

361-
void ConfigParser::SetConfigStringFromRegistry(_In_ HKEY hk, _In_ const char16* subKeyName, _In_ const char16* valName, _Inout_ Js::String& str)
361+
void ConfigParser::SetConfigStringFromRegistry(_In_ HKEY hk, _In_z_ const char16* subKeyName, _In_z_ const char16* valName, _Inout_ Js::String& str)
362362
{
363363
const char16* regValue = nullptr;
364364
DWORD len = 0;
@@ -376,7 +376,7 @@ void ConfigParser::SetConfigStringFromRegistry(_In_ HKEY hk, _In_ const char16*
376376
* doesn't exist, or if we can't allocate memory.
377377
* Will allocate a char16* buffer on the heap. Caller is responsible for freeing.
378378
*/
379-
void ConfigParser::ReadRegistryString(_In_ HKEY hk, _In_ const char16* subKeyName, _In_ const char16* valName, _Out_ const char16** sz, _Out_ DWORD* length)
379+
void ConfigParser::ReadRegistryString(_In_ HKEY hk, _In_z_ const char16* subKeyName, _In_z_ const char16* valName, _Outptr_result_maybenull_z_ const char16** sz, _Out_ DWORD* length)
380380
{
381381
DWORD bufLength = 0;
382382
*length = 0;

lib/Common/Core/ConfigParser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class ConfigParser
4040
void ParseRegistryKey(HKEY hk, CmdLineArgsParser &parser);
4141

4242
#ifdef _WIN32
43-
static void ConfigParser::SetConfigStringFromRegistry(_In_ HKEY hk, _In_ const char16* subKeyName, _In_ const char16* valName, _Inout_ Js::String& str);
44-
static void ConfigParser::ReadRegistryString(_In_ HKEY hk, _In_ const char16* subKeyName, _In_ const char16* valName, _Out_ const char16** sz, _Out_ DWORD* length);
43+
static void ConfigParser::SetConfigStringFromRegistry(_In_ HKEY hk, _In_z_ const char16* subKeyName, _In_z_ const char16* valName, _Inout_ Js::String& str);
44+
static void ConfigParser::ReadRegistryString(_In_ HKEY hk, _In_z_ const char16* subKeyName, _In_z_ const char16* valName, _Outptr_result_maybenull_z_ const char16** sz, _Out_ DWORD* length);
4545
#endif
4646

4747
public:

lib/Runtime/Library/JavascriptLibrary.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,18 +403,20 @@ namespace Js
403403
strictHeapArgumentsTypePath->Add<true /*isSetter*/>(BuiltInPropertyRecords::callee);
404404
strictHeapArgumentsTypePath->Add(BuiltInPropertyRecords::length);
405405
strictHeapArgumentsTypePath->Add(BuiltInPropertyRecords::_symbolIterator);
406-
ObjectSlotAttributes *strictHeapArgumentsAttributes = RecyclerNewArrayLeaf(recycler, ObjectSlotAttributes, strictHeapArgumentsTypePath->GetPathSize());
406+
uint8 strictHeapArgumentsTypePathSize = strictHeapArgumentsTypePath->GetPathSize();
407+
AnalysisAssert(strictHeapArgumentsTypePathSize >= 4);
408+
ObjectSlotAttributes *strictHeapArgumentsAttributes = RecyclerNewArrayLeaf(recycler, ObjectSlotAttributes, strictHeapArgumentsTypePathSize);
407409
strictHeapArgumentsAttributes[0] = (ObjectSlotAttributes)(ObjectSlotAttr_Writable | ObjectSlotAttr_Accessor);
408410
strictHeapArgumentsAttributes[1] = ObjectSlotAttr_Setter;
409411
strictHeapArgumentsAttributes[2] = (ObjectSlotAttributes)PropertyBuiltInMethodDefaults;
410412
strictHeapArgumentsAttributes[3] = (ObjectSlotAttributes)PropertyBuiltInMethodDefaults;
411-
for (int i = 4; i < strictHeapArgumentsTypePath->GetPathSize(); ++i)
413+
for (int i = 4; i < strictHeapArgumentsTypePathSize; ++i)
412414
{
413415
strictHeapArgumentsAttributes[i] = ObjectSlotAttr_Default;
414416
}
415-
PathTypeSetterSlotIndex * strictHeapArgumentsSetters = RecyclerNewArrayLeaf(recycler, PathTypeSetterSlotIndex, strictHeapArgumentsTypePath->GetPathSize());
417+
PathTypeSetterSlotIndex * strictHeapArgumentsSetters = RecyclerNewArrayLeaf(recycler, PathTypeSetterSlotIndex, strictHeapArgumentsTypePathSize);
416418
strictHeapArgumentsSetters[0] = 1;
417-
for (int i = 1; i < strictHeapArgumentsTypePath->GetPathSize(); ++i)
419+
for (int i = 1; i < strictHeapArgumentsTypePathSize; ++i)
418420
{
419421
strictHeapArgumentsSetters[i] = NoSetterSlot;
420422
}

0 commit comments

Comments
 (0)