[coverity] 1543092 Dereference before null check

This commit is contained in:
akallabeth 2024-04-12 10:33:39 +02:00 committed by akallabeth
parent 600c7a8999
commit 1232cdbc6a

View File

@ -1176,6 +1176,14 @@ static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_A
static BOOL freerdp_parse_username_ptr(const char* username, const char** user, size_t* userlen, static BOOL freerdp_parse_username_ptr(const char* username, const char** user, size_t* userlen,
const char** domain, size_t* domainlen) const char** domain, size_t* domainlen)
{ {
WINPR_ASSERT(user);
WINPR_ASSERT(userlen);
WINPR_ASSERT(domain);
WINPR_ASSERT(domainlen);
if (!username)
return FALSE;
const char* p = strchr(username, '\\'); const char* p = strchr(username, '\\');
*user = NULL; *user = NULL;
@ -1193,7 +1201,7 @@ static BOOL freerdp_parse_username_ptr(const char* username, const char** user,
*domain = username; *domain = username;
*domainlen = length; *domainlen = length;
} }
else if (username) else
{ {
/* Do not break up the name for '@'; both credSSP and the /* Do not break up the name for '@'; both credSSP and the
* ClientInfo PDU expect 'user@corp.net' to be transmitted * ClientInfo PDU expect 'user@corp.net' to be transmitted
@ -1202,8 +1210,6 @@ static BOOL freerdp_parse_username_ptr(const char* username, const char** user,
*user = username; *user = username;
*userlen = strlen(username); *userlen = strlen(username);
} }
else
return FALSE;
return TRUE; return TRUE;
} }