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.
@@ -196,7 +196,13 @@ void cmndList(struct SCP_CONNECTION *c)
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++)
{
@@ -211,11 +217,8 @@ void cmndList(struct SCP_CONNECTION *c)
printf("No sessions.\n");
}
- if (0 != dsl)
- {
g_free(dsl);
}
-}
void cmndKill(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
{
