C6335
Aviso C6335: vazamento de identificador de informações do processo <handlename>
Este aviso indica que as alças de informações de processo retornadas pela família de funções CreateProcess precisam ser fechado usando CloseHandle.Se isso haverá vazamento de identificador.
Exemplo
O código a seguir gera este aviso:
#include <windows.h>
#include <stdio.h>
void f( )
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( "C:\\WINDOWS\\system32\\calc.exe",
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si, // Pointer to STARTUPINFO structure.
&pi ) ) // Pointer to PROCESS_INFORMATION
{
puts("Error");
return;
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
}
To correct this warning, call CloseHandle (pi.hThread) to close thread handle as shown in the following code:
#include <windows.h>
#include <stdio.h>
void f( )
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( "C:\\WINDOWS\\system32\\calc.exe",
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si, // Pointer to STARTUPINFO structure.
&pi ) ) // Pointer to PROCESS_INFORMATION
{
puts("Error");
return;
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}