wbemprox: Fix multiple leaks in parse_path (Coverity).

Signed-off-by: Sven Baars <sven.wine@gmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sven Baars 2019-10-04 21:58:43 +02:00 committed by Alexandre Julliard
parent 11470a7763
commit a3b6054afb
1 changed files with 21 additions and 3 deletions

View File

@ -335,24 +335,42 @@ HRESULT parse_path( const WCHAR *str, struct path **ret )
DWORD server_len = ARRAY_SIZE(server); DWORD server_len = ARRAY_SIZE(server);
p++; p++;
if (*p != '\\') return WBEM_E_INVALID_OBJECT_PATH; if (*p != '\\')
{
heap_free( path );
return WBEM_E_INVALID_OBJECT_PATH;
}
p++; p++;
q = p; q = p;
while (*p && *p != '\\') p++; while (*p && *p != '\\') p++;
if (!*p) return WBEM_E_INVALID_OBJECT_PATH; if (!*p)
{
heap_free( path );
return WBEM_E_INVALID_OBJECT_PATH;
}
len = p - q; len = p - q;
if (!GetComputerNameW( server, &server_len ) || server_len != len || wcsnicmp( q, server, server_len )) if (!GetComputerNameW( server, &server_len ) || server_len != len || wcsnicmp( q, server, server_len ))
{
heap_free( path );
return WBEM_E_NOT_SUPPORTED; return WBEM_E_NOT_SUPPORTED;
}
q = ++p; q = ++p;
while (*p && *p != ':') p++; while (*p && *p != ':') p++;
if (!*p) return WBEM_E_INVALID_OBJECT_PATH; if (!*p)
{
heap_free( path );
return WBEM_E_INVALID_OBJECT_PATH;
}
len = p - q; len = p - q;
if (len != ARRAY_SIZE(cimv2W) - 1 || wcsnicmp( q, cimv2W, ARRAY_SIZE(cimv2W) - 1 )) if (len != ARRAY_SIZE(cimv2W) - 1 || wcsnicmp( q, cimv2W, ARRAY_SIZE(cimv2W) - 1 ))
{
heap_free( path );
return WBEM_E_INVALID_NAMESPACE; return WBEM_E_INVALID_NAMESPACE;
}
p++; p++;
} }