From c31cdf53eb8f2ca9d754642fbb43a41fd74a98a4 Mon Sep 17 00:00:00 2001 From: Sanket Parmar Date: Wed, 21 Aug 2013 23:24:11 +0530 Subject: [PATCH] Fixed segfault and added support for single quotes in toxic --- prompt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/prompt.c b/prompt.c index e194a90..6c762c8 100644 --- a/prompt.c +++ b/prompt.c @@ -358,8 +358,16 @@ static void execute(ToxWindow *self, Messenger *m, char *u_cmd) int numargs = 0; for (i = 0; i < MAX_STR_SIZE; i++) { - if (cmd[i] == '\"') - while (cmd[++i] != '\"'); /* skip over strings */ + char quote_chr; + if (cmd[i] == '\"' || cmd[i] == '\'') { + quote_chr = cmd[i]; + while (cmd[++i] != quote_chr && i < MAX_STR_SIZE); /* skip over strings */ + /* Check if got qoute character */ + if (cmd[i] != quote_chr) { + wprintw(self->window, "Missing terminating %c character\n", quote_chr); + return; + } + } if (cmd[i] == ' ') { cmd[i] = '\0';