Skip to content

Commit 1905e36

Browse files
committed
Fix MSVC warning C28112
1 parent dba2ade commit 1905e36

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

phlib/basesup.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,13 +2214,17 @@ PPH_STRING PhReferenceEmptyString(
22142214
PPH_STRING string;
22152215
PPH_STRING newString;
22162216

2217-
string = PhSharedEmptyString;
2217+
string = InterlockedCompareExchangePointer(
2218+
&PhSharedEmptyString,
2219+
NULL,
2220+
NULL
2221+
);
22182222

22192223
if (!string)
22202224
{
22212225
newString = PhCreateStringEx(NULL, 0);
22222226

2223-
string = _InterlockedCompareExchangePointer(
2227+
string = InterlockedCompareExchangePointer(
22242228
&PhSharedEmptyString,
22252229
newString,
22262230
NULL

phlib/lsasup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ LSA_HANDLE PhGetLookupPolicyHandle(
6464

6565
// Use the cached value if possible.
6666

67-
lookupPolicyHandle = cachedLookupPolicyHandle;
67+
lookupPolicyHandle = InterlockedCompareExchangePointer(&cachedLookupPolicyHandle, NULL, NULL);
6868

6969
// If there is no cached handle, open one.
7070

@@ -79,7 +79,7 @@ LSA_HANDLE PhGetLookupPolicyHandle(
7979
// We succeeded in opening a policy handle, and since we did not have a cached handle
8080
// before, we will now store it.
8181

82-
lookupPolicyHandle = _InterlockedCompareExchangePointer(
82+
lookupPolicyHandle = InterlockedCompareExchangePointer(
8383
&cachedLookupPolicyHandle,
8484
newLookupPolicyHandle,
8585
NULL

phlib/util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,14 +2201,14 @@ PPH_STRING PhGetSystemDirectory(
22012201

22022202
// Use the cached value if possible.
22032203

2204-
if (cachedSystemDirectory)
2205-
return PhReferenceObject(cachedSystemDirectory);
2204+
if (systemDirectory = InterlockedCompareExchangePointer(&cachedSystemDirectory, NULL, NULL))
2205+
return PhReferenceObject(systemDirectory);
22062206

22072207
PhGetSystemRoot(&systemRootString);
22082208
systemDirectory = PhConcatStringRef2(&systemRootString, &system32String);
22092209

22102210
// Try to cache the value.
2211-
if (_InterlockedCompareExchangePointer(
2211+
if (InterlockedCompareExchangePointer(
22122212
&cachedSystemDirectory,
22132213
systemDirectory,
22142214
NULL

0 commit comments

Comments
 (0)