From bb5ee93c883d777cebb4252ab7edc21c4e920931 Mon Sep 17 00:00:00 2001 From: AZ Huang Date: Thu, 28 Nov 2013 03:25:56 +0800 Subject: [PATCH] Fix trailing slashes which leads to segfault. --- src/chat.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/chat.c b/src/chat.c index 52cfec4..47a2205 100644 --- a/src/chat.c +++ b/src/chat.c @@ -109,6 +109,11 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int num, uint8_t fil ChatContext *ctx = (ChatContext *) self->chatwin; + int idx = strlen(pathname) - 1; + while (pathname[idx] == '/') { + pathname[idx--] = 0; + } + /* try to get file name from path */ uint8_t *filename = strrchr(pathname, '/'); // Try unix style paths