FreeRDP/FreeRDP — Issue #385: redirection: fix code for sharing data
Author: nfedera
Created: 2012-02-01 17:17:12+00:00
State: open

Today I fixed a freerdp segv which happened continuously during program termination because redirection_free() calls freerdp_blob_free(redirection->password_cookie) which is NULL (most of the time).
Fixing only this single crash was easy but when looking at the code in more detail it became obvious that the current way of sharing redirection specific data (username, domain, password_cookie, ...) between redirection.c, info.c connection.c and settings.c is horrible.
Don't have time to fix this now ... thus I'm adding this issue to log the problem.
settings.c and redirection.c both try to free e.g. their domain, username, ... structures.
In connections.c pointers of structures allocated in settings.c are changed to point to internal elements of structures allocated in redirect.c:
E.g. in connection.c/rdp_client_redirect():
if (redirection->flags & LB_USERNAME)
{
xfree(settings->username);
settings->username = redirection->username.ascii;
}
And redirect.c in turn sets ascii pointers of its' self-allocated string structures to NULL to avoid segfaults when calling freerdp_string_free because settings.c might have freed these already ... not good ;)

So we should either copy the stuff from one structure to the other or modify only the foreign structure but not mix pointers between them and add glue code to avoid segfaults.