ii

git clone https://orangeshoelaces.net/git/ii.git

95c3aa1624f47d0cad8a77541ab876b3b078a243

Author: nion@noname on 01/29/2006

Committer: nion@noname on 01/29/2006

segfault fix with gcc-2.95 thanks florolf for help

Stats

ii.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/ii.c b/ii.c
index c582032..68dc63c 100644
--- a/ii.c
+++ b/ii.c
@@ -197,7 +197,8 @@ static size_t tokenize(char **result, size_t reslen, char *str, char delim)
 		} else
 			n++;
 	}
-	result[i++] = p;
+	if(i<reslen)
+		result[i++] = p;
 	return i + 2;				/* number of tokens */
 }
 
@@ -329,7 +330,7 @@ static void proc_server_cmd(char *buf)
 		*p = 0;
 		argv[TOK_TEXT] = ++p;
 	}
-	tokenize(&argv[TOK_CMD], TOK_LAST - TOK_CMD + 1, cmd, ' ');
+	tokenize(&argv[TOK_CMD], TOK_LAST - TOK_CMD, cmd, ' ');
 
 	if(!strncmp("PING", argv[TOK_CMD], 5)) {
 		snprintf(message, PIPE_BUF, "PONG %s\r\n", argv[TOK_TEXT]);