diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2008-04-21 22:53:15 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2008-04-21 22:53:15 +0100 | 
| commit | 99f929cb5faca663969361e4a142d0c309af1725 (patch) | |
| tree | 56978526a17da23975b70b378b54a0b87bbd0c4a | |
| parent | aefaac3a5d44537bdf804d1f42e491cc2b931889 (diff) | |
Now checking if msn_sb_create() returns NULL. This is very unlikely, but
can happen if we run out of file descriptors, for example.
| -rw-r--r-- | protocols/msn/ns.c | 24 | 
1 files changed, 21 insertions, 3 deletions
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index ff7da6ed..ffaa90a7 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -177,7 +177,15 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )  			}  			debug( "Connecting to a new switchboard with key %s", cmd[5] ); -			sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ); + +			if( ( sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ) ) == NULL ) +			{ +				/* Although this isn't strictly fatal for the NS connection, it's +				   definitely something serious (we ran out of file descriptors?). */ +				imcb_error( ic, "Could not create new switchboard" ); +				imc_logout( ic, TRUE ); +				return( 0 ); +			}  			if( md->msgq )  			{ @@ -467,8 +475,18 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )  		debug( "Got a call from %s (session %d). Key = %s", cmd[5], session, cmd[4] ); -		sb = msn_sb_create( ic, server, port, cmd[4], session ); -		sb->who = g_strdup( cmd[5] ); +		if( ( sb = msn_sb_create( ic, server, port, cmd[4], session ) ) == NULL ) +		{ +			/* Although this isn't strictly fatal for the NS connection, it's +			   definitely something serious (we ran out of file descriptors?). */ +			imcb_error( ic, "Could not create new switchboard" ); +			imc_logout( ic, TRUE ); +			return( 0 ); +		} +		else +		{ +			sb->who = g_strdup( cmd[5] ); +		}  	}  	else if( strcmp( cmd[0], "ADD" ) == 0 )  	{  | 
