From 81230295cca9702ae2b7dd69f2e21f2860d77437 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Sun, 24 Nov 2013 15:18:05 -0500 Subject: [PATCH] fix possible bug --- src/misc_tools.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/misc_tools.c b/src/misc_tools.c index 2221b7d..005c8da 100644 --- a/src/misc_tools.c +++ b/src/misc_tools.c @@ -117,10 +117,12 @@ void alert_window(ToxWindow *self) /* case-insensitive string compare function for use with qsort - same return logic as strcmp */ int name_compare(const void *nick1, const void *nick2) { - char s[strlen(nick1)]; - char t[strlen(nick2)]; - strcpy(s, (const char*) nick1); - strcpy(t, (const char*) nick2); + int len_s = strlen((const char *) nick1); + int len_t = strlen((const char *) nick2); + char s[len_s]; + char t[len_t]; + strcpy(s, (const char *) nick1); + strcpy(t, (const char *) nick2); int i; @@ -133,4 +135,4 @@ int name_compare(const void *nick1, const void *nick2) } return s[i] - t[i]; -} \ No newline at end of file +}