From 3b32017ca4d13d1385c8c96eef14fcd62ba17464 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 19 Aug 2008 23:21:07 +0100 Subject: Better handling of NULLs passed to set_eval_account(). Still confusing though, set_reset() is broken for variables that can actually be NULL. --- account.c | 32 ++++++++++++++++++-------------- 1 file 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 ) ) -- cgit v1.2.3