You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> warning C6333: Invalid parameter: passing MEM_RELEASE and a non-zero dwSize parameter to \<function> is not allowed. This results in the failure of this call
12
+
> Invalid parameter: passing MEM_RELEASE and a non-zero dwSize parameter to '\**function_name*' is not allowed. This results in the failure of this call
13
13
14
-
This warning indicates an invalid parameter is being passed to VirtualFree or VirtualFreeEx. Both of these functions reject a dwFreeType of MEM_RELEASE with a non-zero value of dwSize. When passing MEM_RELEASE, the dwSize parameter must be zero. Also, make sure that the return value of this function is not ignored.
14
+
## Remarks
15
+
16
+
Both `VirtualFree` and `VirtualFreeEx` reject a `dwFreeType` of `MEM_RELEASE` with a non-zero value of `dwSize`. When passing `MEM_RELEASE`, the `dwSize` parameter must be zero.
17
+
18
+
Code analysis name: VIRTUALFREEINVALIDPARAM3
15
19
16
20
## Example
17
21
18
-
The following sample code generates this warning:
22
+
The following code sample generates this warning:
19
23
20
24
```cpp
21
25
#include<windows.h>
@@ -24,36 +28,36 @@ The following sample code generates this warning:
24
28
DWORD dwPages = 0; // count of pages
25
29
DWORD dwPageSize; // page size
26
30
27
-
VOID f(VOID)
31
+
VOID f(VOID)
28
32
{
29
-
LPVOID lpvBase; // base address of the test memory
30
-
BOOL bSuccess;
31
-
SYSTEM_INFO sSysInfo; // system information
32
-
33
-
GetSystemInfo(&sSysInfo);
34
-
dwPageSize = sSysInfo.dwPageSize;
35
-
36
-
// Reserve pages in the process's virtual address space
You can also use VirtualFree(lpvBase, PAGELIMIT * dwPageSize, MEM_DECOMMIT); call to decommit pages, and later release them using MEM_RELEASE flag.
99
+
You can also use `VirtualFree(lpvBase, PAGELIMIT * dwPageSize, MEM_DECOMMIT);` call to decommit pages, and later release them using `MEM_RELEASE` flag.
0 commit comments