diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2008-08-19 23:21:07 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2008-08-19 23:21:07 +0100 | 
| commit | 3b32017ca4d13d1385c8c96eef14fcd62ba17464 (patch) | |
| tree | 118ed70efec5423941fcb89a3d39c8354afb8b53 | |
| parent | a8305126a38eb977c51046dd4ec3ac258a20a98f (diff) | |
Better handling of NULLs passed to set_eval_account(). Still confusing
though, set_reset() is broken for variables that can actually be NULL.
| -rw-r--r-- | account.c | 32 | 
1 files changed, 18 insertions, 14 deletions
| @@ -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 ) ) | 
