Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 6587002

Browse files
malxau-msftmalxau
andauthored
Enable SdlCheck and fix warning for use of uninitialized pointer value (#438)
Co-authored-by: Malcolm <[email protected]>
1 parent 654f88e commit 6587002

File tree

8 files changed

+67
-25
lines changed

8 files changed

+67
-25
lines changed

build/Winfile.props

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,42 @@
1111
<GenerateDebugInformation>true</GenerateDebugInformation>
1212
</Link>
1313
</ItemDefinitionGroup>
14-
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='DebugXPStatic'">
14+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
1515
<ClCompile>
1616
<Optimization>Disabled</Optimization>
1717
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
18-
<RuntimeLibrary Condition="'$(Configuration)'=='Debug'">MultiThreadedDebugDLL</RuntimeLibrary>
19-
<RuntimeLibrary Condition="'$(Configuration)'=='DebugXPStatic'">MultiThreadedDebug</RuntimeLibrary>
20-
<EnableEnhancedInstructionSet Condition="'$(Configuration)'=='DebugXPStatic'">NoExtensions</EnableEnhancedInstructionSet>
18+
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
19+
<SdlCheck>true</SdlCheck>
2120
</ClCompile>
2221
</ItemDefinitionGroup>
23-
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release' or '$(Configuration)'=='ReleaseXPStatic'">
22+
<ItemDefinitionGroup Condition="'$(Configuration)'=='DebugXPStatic'">
23+
<ClCompile>
24+
<Optimization>Disabled</Optimization>
25+
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
26+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
27+
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
28+
</ClCompile>
29+
</ItemDefinitionGroup>
30+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
2431
<ClCompile>
2532
<Optimization>MaxSpeed</Optimization>
2633
<FunctionLevelLinking>true</FunctionLevelLinking>
2734
<IntrinsicFunctions>true</IntrinsicFunctions>
28-
<RuntimeLibrary Condition="'$(Configuration)'=='Release'">MultiThreadedDLL</RuntimeLibrary>
29-
<RuntimeLibrary Condition="'$(Configuration)'=='ReleaseXPStatic'">MultiThreaded</RuntimeLibrary>
30-
<EnableEnhancedInstructionSet Condition="'$(Configuration)'=='ReleaseXPStatic'">NoExtensions</EnableEnhancedInstructionSet>
31-
<Optimization Condition="'$(Configuration)'=='ReleaseXPStatic'">MinSpace</Optimization>
35+
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
36+
<SdlCheck>true</SdlCheck>
37+
</ClCompile>
38+
<Link>
39+
<OptimizeReferences>true</OptimizeReferences>
40+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
41+
</Link>
42+
</ItemDefinitionGroup>
43+
<ItemDefinitionGroup Condition="'$(Configuration)'=='ReleaseXPStatic'">
44+
<ClCompile>
45+
<Optimization>MinSpace</Optimization>
46+
<FunctionLevelLinking>true</FunctionLevelLinking>
47+
<IntrinsicFunctions>true</IntrinsicFunctions>
48+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
49+
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
3250
</ClCompile>
3351
<Link>
3452
<OptimizeReferences>true</OptimizeReferences>

src/treectl.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,19 +616,19 @@ ReadDirLevel(
616616
LPTSTR szAutoExpand,
617617
BOOL bPartialSort)
618618
{
619-
LPWSTR szEndPath;
619+
LPWSTR szEndPath;
620620
LFNDTA lfndta;
621621
INT iNode;
622622
BOOL bFound;
623-
PDNODE pNode;
623+
PDNODE pNode;
624624
BOOL bAutoExpand;
625625
BOOL bResult = TRUE;
626626
DWORD dwView;
627627
HWND hwndParent;
628628
HWND hwndDir;
629629
LPXDTALINK lpStart;
630-
LPXDTA* plpxdta;
631-
LPXDTA lpxdta;
630+
LPXDTA* plpxdta;
631+
LPXDTA lpxdta;
632632
INT count;
633633

634634
UINT uYieldCount = 0;
@@ -649,6 +649,8 @@ ReadDirLevel(
649649
//
650650

651651
lpStart = NULL;
652+
plpxdta = NULL;
653+
lpxdta = NULL;
652654

653655
if (!(dwView & VIEW_PLUSES)) {
654656

@@ -1034,6 +1036,8 @@ StealTreeData(
10341036
DWORD dwView;
10351037
DWORD dwAttribs;
10361038

1039+
hwndT = NULL;
1040+
10371041
//
10381042
// we need to match on these attributes as well as the name
10391043
//
@@ -1159,6 +1163,7 @@ FillTreeListbox(HWND hwndTC,
11591163
BOOL bPartialSort;
11601164
DRIVE drive;
11611165

1166+
pNode = NULL;
11621167

11631168
hwndLB = GetDlgItem(hwndTC, IDCW_TREELISTBOX);
11641169

@@ -1226,7 +1231,9 @@ FillTreeListbox(HWND hwndTC,
12261231
FindItemFromPath(hwndLB, szDefaultDir, FALSE, NULL, &pNode);
12271232
}
12281233

1229-
SendMessage(hwndLB, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)pNode);
1234+
if (pNode != NULL) {
1235+
SendMessage(hwndLB, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)pNode);
1236+
}
12301237

12311238
UpdateStatus(GetParent(hwndTC)); // Redraw the Status Bar
12321239

@@ -3170,6 +3177,7 @@ TreeControlWndProc(
31703177
BOOL bDir;
31713178
BOOL bChangeDisplay = FALSE;
31723179

3180+
hwndNext = NULL;
31733181
TypeAheadString('\0', NULL);
31743182
GetTreeWindows(hwndParent, NULL, &hwndDir);
31753183

@@ -3207,7 +3215,7 @@ TreeControlWndProc(
32073215
}
32083216
else
32093217
{
3210-
hwndSet = hwnd;
3218+
hwndSet = hwnd;
32113219
}
32123220
}
32133221
}

src/wfassoc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,9 @@ ClassesRead(HKEY hKey,
17831783

17841784
iKey = 0;
17851785

1786+
pFileType = NULL;
1787+
pExt = NULL;
1788+
17861789
pFileTypePrev = *ppFileTypeBase;
17871790
pExtPrev = *ppExtBase;
17881791

src/wfcopy.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ JAPANBEGIN
265265
// Allocate enough space for 8.3 conversion to DBCS here (each
266266
// part done individually, so 8 chars is enough).
267267
//
268-
LPSTR pOrigA;
268+
LPSTR pOrigA = NULL;
269269
CHAR szOrigA[8*2];
270270
JAPANEND
271271

@@ -1403,6 +1403,7 @@ GetNextPair(PCOPYROOT pcr, LPTSTR pFrom,
14031403
STKCHK();
14041404
*pFrom = CHAR_NULL;
14051405
*pdwError = 0 ;
1406+
pDTA = NULL;
14061407

14071408
//
14081409
// Keep recursing directory structure until we get to the bottom
@@ -2224,7 +2225,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
22242225
{
22252226
PCOPYINFO pCopyInfo = lpParameter;
22262227
DWORD ret = 0; // Return value from WFMoveCopyDriver
2227-
LPWSTR pSpec; // Pointer to file spec
2228+
LPWSTR pSpec = NULL; // Pointer to file spec
22282229
DWORD dwAttr; // File attributes
22292230
DWORD dwResponse; // Response from ConfirmDialog call
22302231
DWORD oper = 0; // Disk operation being performed
@@ -2235,7 +2236,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
22352236

22362237
TCHAR szSource[MAXPATHLEN]; // Source file (ANSI string)
22372238
LFNDTA DTADest; // DTA block for reporting dest errors
2238-
PLFNDTA pDTA; // DTA pointer for source errors
2239+
PLFNDTA pDTA = NULL; // DTA pointer for source errors
22392240
PCOPYROOT pcr; // Structure for searching source tree
22402241
BOOL bReplaceAll = FALSE; // Replace all flag
22412242
BOOL bSubtreeDelAll = FALSE; // Delete entire subtree flag

src/wfdir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,8 @@ ChangeDisplay(
13181318

13191319
case WM_CREATE:
13201320

1321+
lpStart = NULL;
1322+
13211323
//
13221324
// dwNewView, dwNewSort and dwNewAttribs define the viewing
13231325
// parameters of the new window (GLOBALS)

src/wfdrives.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ DrivesWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
749749
BOOL bDir;
750750
BOOL bChangeDisplay = FALSE;
751751

752+
hwndNext = NULL;
753+
752754
GetTreeWindows(hwndChild, &hwndTree, &hwndDir);
753755

754756
// Check to see if we can change to the directory window

src/wfinfo.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,8 @@ UpdateDriveListWorker(VOID)
10591059

10601060
INT iUpdatePhantom = iUpdateReal ^ 1;
10611061

1062+
hEnum = NULL;
1063+
10621064

10631065
//
10641066
// GetLogicalDrives simply calls GetDriveType,
@@ -1313,11 +1315,13 @@ UpdateDriveListWorker(VOID)
13131315
rgiDriveReal[iUpdatePhantom][i] = 0;
13141316
}
13151317

1316-
if (bOpenEnumSucceed)
1318+
if (bOpenEnumSucceed) {
13171319
WNetCloseEnum(hEnum);
1320+
}
13181321

1319-
if (pcBuf)
1322+
if (pcBuf) {
13201323
LocalFree((HANDLE)pcBuf);
1324+
}
13211325

13221326

13231327
PostMessage(hwndFrame, FS_UPDATEDRIVETYPECOMPLETE, (WPARAM)cRealDrives, 0L);

src/wfutil.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,9 +1122,11 @@ SetDlgDirectory(HWND hDlg, LPTSTR pszPath)
11221122
HWND hDlgItem;
11231123
HANDLE hFont;
11241124
HANDLE hFontBak;
1125-
TCHAR szPath[MAXPATHLEN+5];
1126-
TCHAR szTemp[MAXPATHLEN+20];
1127-
TCHAR szMessage[MAXMESSAGELEN];
1125+
TCHAR szPath[MAXPATHLEN+5];
1126+
TCHAR szTemp[MAXPATHLEN+20];
1127+
TCHAR szMessage[MAXMESSAGELEN];
1128+
1129+
hFontBak = NULL;
11281130

11291131
if (pszPath)
11301132
lstrcpy(szPath, pszPath);
@@ -1143,14 +1145,16 @@ SetDlgDirectory(HWND hDlg, LPTSTR pszPath)
11431145
// This is required because Japanese Windows uses System font
11441146
// for dialog box
11451147
//
1146-
if (hFont)
1148+
if (hFont) {
11471149
hFontBak = SelectObject(hDC, hFont);
1150+
}
11481151

11491152
GetTextExtentPoint32(hDC, szMessage, lstrlen(szMessage), &size);
11501153
CompactPath(hDC, szPath, (rc.right-rc.left-size.cx));
11511154

1152-
if (hFont)
1155+
if (hFont) {
11531156
SelectObject(hDC, hFontBak);
1157+
}
11541158

11551159
ReleaseDC(hDlg, hDC);
11561160
wsprintf(szTemp, szMessage, szPath);

0 commit comments

Comments
 (0)