aboutsummaryrefslogtreecommitdiffstats
path: root/account.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2008-08-19 23:21:07 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2008-08-19 23:21:07 +0100
commit3b32017ca4d13d1385c8c96eef14fcd62ba17464 (patch)
tree118ed70efec5423941fcb89a3d39c8354afb8b53 /account.c
parenta8305126a38eb977c51046dd4ec3ac258a20a98f (diff)
Better handling of NULLs passed to set_eval_account(). Still confusing
though, set_reset() is broken for variables that can actually be NULL.
Diffstat (limited to 'account.c')
-rw-r--r--account.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/account.c b/account.c
index 07df69e4..c7480996 100644
--- a/account.c
+++ b/account.c
@@ -78,22 +78,10 @@ char *set_eval_account( set_t *set, char *value )
if( set->flags & ACC_SET_OFFLINE_ONLY && acc->ic )
return NULL;
- if( strcmp( set->key, "username" ) == 0 )
- {
- g_free( acc->user );
- acc->user = g_strdup( value );
- return value;
- }
- else if( strcmp( set->key, "password" ) == 0 )
- {
- g_free( acc->pass );
- acc->pass = g_strdup( value );
- return NULL; /* password shouldn't be visible in plaintext! */
- }
- else if( strcmp( set->key, "server" ) == 0 )
+ if( strcmp( set->key, "server" ) == 0 )
{
g_free( acc->server );
- if( *value )
+ if( value && *value )
{
acc->server = g_strdup( value );
return value;
@@ -104,6 +92,22 @@ char *set_eval_account( set_t *set, char *value )
return g_strdup( set->def );
}
}
+ else if( value == NULL )
+ {
+ /* Noop, the other three can't be NULL. */
+ }
+ else if( strcmp( set->key, "username" ) == 0 )
+ {
+ g_free( acc->user );
+ acc->user = g_strdup( value );
+ return value;
+ }
+ else if( strcmp( set->key, "password" ) == 0 )
+ {
+ g_free( acc->pass );
+ acc->pass = g_strdup( value );
+ return NULL; /* password shouldn't be visible in plaintext! */
+ }
else if( strcmp( set->key, "auto_connect" ) == 0 )
{
if( !is_bool( value ) )