From e1720ce8958ae014ce38d03b7b9ab129d947921b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Dec 2008 01:38:59 +0000 Subject: Fixed a bug in the IRC parser where lines that start with a colon and don't contain any spaces could make BitlBee read uninitialized memory (and possibly even parse it as if it were a command). Also fixed a small memory leak around there. --- irc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/irc.c b/irc.c index 10b4fd83..2dcc625d 100644 --- a/irc.c +++ b/irc.c @@ -406,10 +406,8 @@ void irc_process( irc_t *irc ) lines[i] = conv; } - if( lines[i] ) + if( lines[i] && ( cmd = irc_parse_line( lines[i] ) ) ) { - if( ( cmd = irc_parse_line( lines[i] ) ) == NULL ) - continue; irc_exec( irc, cmd ); g_free( cmd ); } @@ -484,7 +482,7 @@ char **irc_parse_line( char *line ) /* Move the line pointer to the start of the command, skipping spaces and the optional prefix. */ if( line[0] == ':' ) { - for( i = 0; line[i] != ' '; i ++ ); + for( i = 0; line[i] && line[i] != ' '; i ++ ); line = line + i; } for( i = 0; line[i] == ' '; i ++ ); -- cgit v1.2.3