xrdp-sesadmin: fix crash on network or authentication error

If scp_v1c_mng_get_session_list() returns an error, report it to the
user and exit. Session list is not initialized in that case and should
not be freed.

g_free() already checks its argument for being to NULL, remove an extra
check.
This commit is contained in:
Pavel Roskin 2017-01-25 23:32:57 +00:00 committed by jsorg71
parent 021b79ba55
commit 0017081d78

View File

@ -196,7 +196,13 @@ void cmndList(struct SCP_CONNECTION *c)
e = scp_v1c_mng_get_session_list(c, &scnt, &dsl); e = scp_v1c_mng_get_session_list(c, &scnt, &dsl);
if ((SCP_CLIENT_STATE_LIST_OK == e) && (scnt > 0)) if (e != SCP_CLIENT_STATE_LIST_OK)
{
printf("Error getting session list.\n");
return;
}
if (scnt > 0)
{ {
for (idx = 0; idx < scnt; idx++) for (idx = 0; idx < scnt; idx++)
{ {
@ -211,10 +217,7 @@ void cmndList(struct SCP_CONNECTION *c)
printf("No sessions.\n"); printf("No sessions.\n");
} }
if (0 != dsl) g_free(dsl);
{
g_free(dsl);
}
} }
void cmndKill(struct SCP_CONNECTION *c, struct SCP_SESSION *s) void cmndKill(struct SCP_CONNECTION *c, struct SCP_SESSION *s)