Skip to content

Commit 7a33be8

Browse files
committed
Fix SAL warnings
1 parent eaf0fea commit 7a33be8

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

phlib/include/phutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ PHLIBAPI
918918
BOOLEAN
919919
NTAPI
920920
PhShowFileDialog(
921-
_In_ HWND hWnd,
921+
_In_opt_ HWND hWnd,
922922
_In_ PVOID FileDialog
923923
);
924924

phlib/util.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,7 +3529,7 @@ VOID PhShellOpenKey(
35293529

35303530
RtlInitUnicodeString(&valueName, L"LastKey");
35313531
lastKey = PhExpandKeyName(KeyName, TRUE);
3532-
NtSetValueKey(regeditKeyHandle, &valueName, 0, REG_SZ, lastKey->Buffer, (ULONG)lastKey->Length + 2);
3532+
NtSetValueKey(regeditKeyHandle, &valueName, 0, REG_SZ, lastKey->Buffer, (ULONG)lastKey->Length + sizeof(UNICODE_NULL));
35333533
PhDereferenceObject(lastKey);
35343534

35353535
NtClose(regeditKeyHandle);
@@ -3583,8 +3583,8 @@ PPH_STRING PhQueryRegistryString(
35833583
buffer->Type == REG_MULTI_SZ ||
35843584
buffer->Type == REG_EXPAND_SZ)
35853585
{
3586-
if (buffer->DataLength >= sizeof(WCHAR))
3587-
string = PhCreateStringEx((PWCHAR)buffer->Data, buffer->DataLength - sizeof(WCHAR));
3586+
if (buffer->DataLength >= sizeof(UNICODE_NULL))
3587+
string = PhCreateStringEx((PWCHAR)buffer->Data, buffer->DataLength - sizeof(UNICODE_NULL));
35883588
else
35893589
string = PhReferenceEmptyString();
35903590
}
@@ -3786,9 +3786,7 @@ OPENFILENAME *PhpCreateOpenFileName(
37863786
{
37873787
OPENFILENAME *ofn;
37883788

3789-
ofn = PhAllocate(sizeof(OPENFILENAME));
3790-
memset(ofn, 0, sizeof(OPENFILENAME));
3791-
3789+
ofn = PhAllocateZero(sizeof(OPENFILENAME));
37923790
ofn->lStructSize = sizeof(OPENFILENAME);
37933791
ofn->nMaxFile = 0x400;
37943792
ofn->lpstrFile = PhAllocate(ofn->nMaxFile * sizeof(WCHAR));
@@ -3939,7 +3937,7 @@ VOID PhFreeFileDialog(
39393937
* occurred.
39403938
*/
39413939
BOOLEAN PhShowFileDialog(
3942-
_In_ HWND hWnd,
3940+
_In_opt_ HWND hWnd,
39433941
_In_ PVOID FileDialog
39443942
)
39453943
{
@@ -4186,7 +4184,7 @@ VOID PhSetFileDialogFilter(
41864184
if (ofn->lpstrFilter)
41874185
PhFree((PVOID)ofn->lpstrFilter);
41884186

4189-
ofn->lpstrFilter = PhAllocateCopy(filterString->Buffer, filterString->Length + 2);
4187+
ofn->lpstrFilter = PhAllocateCopy(filterString->Buffer, filterString->Length + sizeof(UNICODE_NULL));
41904188
PhDereferenceObject(filterString);
41914189
}
41924190
}

0 commit comments

Comments
 (0)