Skip to content

Commit 8635d0b

Browse files
qiutongMSQiutong Shen
andauthored
Fix PREfast Warning C26495, and excluded the generated file path for prefast task (#5556)
* fix MRTBuild warnings * fix in dev and test * change excludedPath for prefast task for x64 * use ZeroMemory replace memset; use replace __t --------- Co-authored-by: Qiutong Shen <qiutongshen@microsoft.com>
1 parent 1b41b23 commit 8635d0b

File tree

15 files changed

+43
-7
lines changed

15 files changed

+43
-7
lines changed

build/AzurePipelinesTemplates/WindowsAppSDK-BuildFoundation-Steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ steps:
8484
msBuildCommandline: 'msbuild.exe /restore /nologo /nr:false /p:configuration=Release /p:platform=x64 $(Build.SourcesDirectory)\WindowsAppRuntime.sln'
8585
# Generally speaking, we leave it to the external repos to scan the bits in their packages.
8686
excludedPaths: |
87-
$(Build.SourcesDirectory)\packages
87+
$(Agent.ToolsDirectory)\uCRT\#$(Build.SourcesDirectory)\obj\$(buildConfiguration)\$(buildPlatform)#$(Build.SourcesDirectory)\packages
8888
env:
8989
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
9090
continueOnError: true

dev/BackgroundTask/BackgroundTaskBuilder/BackgroundTaskBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace winrt::Microsoft::Windows::ApplicationModel::Background::implementatio
1010
{
1111
struct BackgroundTaskBuilder : BackgroundTaskBuilderT<BackgroundTaskBuilder>
1212
{
13-
BackgroundTaskBuilder()
13+
BackgroundTaskBuilder(): m_taskEntryPointClsid{}
1414
{
1515
THROW_HR_IF(E_NOTIMPL, !::Microsoft::Windows::ApplicationModel::Background::Feature_BackgroundTask::IsEnabled());
1616
}

dev/Detours/disasm.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ CDetourDis::CDetourDis(_Out_opt_ PBYTE *ppbTarget, _Out_opt_ LONG *plExtra)
334334
m_bF3 = FALSE;
335335
m_bVex = FALSE;
336336
m_bEvex = FALSE;
337+
m_nSegmentOverride = 0;
338+
m_lScratchExtra = 0;
339+
m_pbScratchTarget = nullptr;
340+
ZeroMemory(m_rbScratchDst, sizeof(m_rbScratchDst));
337341

338342
m_ppbTarget = ppbTarget ? ppbTarget : &m_pbScratchTarget;
339343
m_plExtra = plExtra ? plExtra : &m_lScratchExtra;
@@ -3562,6 +3566,7 @@ CDetourDis::CDetourDis()
35623566
m_pbTarget = (PBYTE)DETOUR_INSTRUCTION_TARGET_NONE;
35633567
m_pbPool = NULL;
35643568
m_lExtra = 0;
3569+
ZeroMemory(m_rbScratchDst, sizeof(m_rbScratchDst));
35653570
}
35663571

35673572
PBYTE CDetourDis::CopyInstruction(PBYTE pDst,
@@ -3965,6 +3970,7 @@ BYTE CDetourDis::PureCopy32(BYTE* pSource, BYTE* pDest)
39653970
CDetourDis::CDetourDis()
39663971
{
39673972
m_pbTarget = (PBYTE)DETOUR_INSTRUCTION_TARGET_NONE;
3973+
ZeroMemory(m_rbScratchDst, sizeof(m_rbScratchDst));
39683974
}
39693975

39703976
PBYTE CDetourDis::CopyInstruction(PBYTE pDst,

dev/Detours/image.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,25 @@ CImage::CImage()
775775
m_hMap = NULL;
776776
m_pMap = NULL;
777777

778+
m_nNextFileAddr = 0;
779+
m_nNextVirtAddr = 0;
780+
781+
ZeroMemory(&m_DosHeader, sizeof(m_DosHeader));
782+
ZeroMemory(&m_NtHeader, sizeof(m_NtHeader));
783+
ZeroMemory(&m_SectionHeaders, sizeof(m_SectionHeaders));
784+
785+
m_nPrePE = 0;
786+
m_cbPrePE = 0;
787+
m_cbPostPE = 0;
788+
778789
m_nPeOffset = 0;
779790
m_nSectionsOffset = 0;
791+
m_nExtraOffset = 0;
792+
m_nFileSize = 0;
793+
794+
m_nOutputVirtAddr = 0;
795+
m_nOutputVirtSize = 0;
796+
m_nOutputFileAddr = 0;
780797

781798
m_pbOutputBuffer = NULL;
782799
m_cbOutputBuffer = 0;

dev/MRTCore/mrt/mrm/UnitTests/StringResult.UnitTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct StringResult_Struct
4242

4343
StringResult_Struct()
4444
{
45+
origRef = nullptr;
4546
shortStr = L"Bye!";
4647
medStr = L"Hello!";
4748
concatStr = L" What's Up?";

dev/MRTCore/mrt/mrm/UnitTests/TestFileUtils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ namespace UnitTests
1515
{
1616

1717
FileBasedTest::FileBasedTest() : m_runFrom(Current), m_pTestClassName(nullptr), m_pTestMethodName(nullptr), m_pClassDataSubfolder(nullptr)
18-
{}
18+
{
19+
m_originalDir[0] = L'\0';
20+
}
1921

2022
DWORD
2123
FileBasedTest::CreateDirectoryHierarchy(_In_ const WEX::Common::String& path)

dev/MRTCore/mrt/mrm/UnitTests/TestReverseMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace WEX::Logging;
1515
namespace UnitTests
1616
{
1717

18-
TestReverseFileMap::TestReverseFileMap() : m_build(), m_pPriBuilder(NULL), m_pReverseFileMapBuilder(NULL), m_pReverseFileMap(NULL) {}
18+
TestReverseFileMap::TestReverseFileMap() : m_build(), m_pPriBuilder(NULL), m_pReverseFileMapBuilder(NULL), m_pReverseFileMap(NULL), m_pTestDI(nullptr), m_testDI(), m_pDecisionInfo(nullptr) {}
1919

2020
HRESULT
2121
TestReverseFileMap::InitFromTestVars(__in PriSectionBuilder* pPriBuilder, __in UnifiedEnvironment* pEnvironment, __in PCWSTR pVarPrefix)

dev/MRTCore/mrt/mrm/UnitTests/testEnvironment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ TestEnvironment::GetQualifierInfo(_In_ INT32 evIndex, _Outptr_ const QUALIFIER_I
405405
return E_NOTIMPL;
406406
}
407407

408-
TestEnvironmentCollection::TestEnvironmentCollection() {}
408+
TestEnvironmentCollection::TestEnvironmentCollection() : m_pEnvironments(nullptr) {}
409409

410410
TestEnvironmentCollection::~TestEnvironmentCollection() { delete m_pEnvironments; }
411411

dev/MRTCore/mrt/mrm/UnitTests/testMap.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ TestResourceMap::TestResourceMap() :
2121
m_build(),
2222
m_pPriBuilder(nullptr),
2323
m_pMapBuilder(nullptr),
24+
m_pSchemaBuilder(nullptr),
2425
m_pMap(nullptr),
26+
m_pTestDI(nullptr),
2527
m_pMyMapBuilder(nullptr),
2628
m_pMySchemaBuilder(nullptr),
29+
m_testDI(),
2730
m_pBaselinePri(nullptr),
2831
m_expectedFinalizeResult(0),
2932
m_expectedFinalizeReturn(true),

dev/MRTCore/mrt/mrm/UnitTests/testPri.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ TestHPri::TestHPri() :
2525
m_buffer(nullptr),
2626
m_bufferSizeInBytes(0),
2727
m_pri(nullptr),
28+
m_testDI(),
29+
m_testEnvironment(nullptr),
30+
m_qualifierMappingBuilder(nullptr),
2831
m_baselinePri(nullptr),
2932
m_expectedFinalizeResult(0),
3033
m_expectedFinalizeReturn(true),

0 commit comments

Comments
 (0)