# HG changeset patch # User Mikael Berthe # Date 1157184085 -7200 # Node ID 27a7b2f986f52d1c02c2e98ae9caaaf12939b32b # Parent 1757f8b03b8f70d4f3279343cb1712031131e789 Fix a freeze with UTF-8 locales Some commands cause an infinite loop when using an utf-8 locale. It occurs when a screen refresh is done and there are trailing spaces in the command line. This patch should fix it. (Problem reported by "AL" in the mcabber conference room) diff -r 1757f8b03b8f -r 27a7b2f986f5 mcabber/src/commands.c --- a/mcabber/src/commands.c Sun Aug 27 10:07:59 2006 +0200 +++ b/mcabber/src/commands.c Sat Sep 02 10:01:25 2006 +0200 @@ -321,18 +321,22 @@ char *xpline; cmd *curcmd; - // Remove trailing spaces: - for (p=line ; *p ; p++) - ; - for (p-- ; p>line && (*p == ' ') ; p--) - *p = 0; - // We do alias expansion here if (scr_get_multimode() != 2) xpline = expandalias(line); else xpline = line; // No expansion in verbatim multi-line mode + // We want to have a copy + if (xpline == line) + xpline = g_strdup(line); + + // Remove trailing spaces: + for (p=xpline ; *p ; p++) + ; + for (p-- ; p>xpline && (*p == ' ') ; p--) + *p = 0; + // Command "quit"? if ((!strncasecmp(xpline, "/quit", 5)) && (scr_get_multimode() != 2) ) if (!xpline[5] || xpline[5] == ' ') @@ -342,6 +346,7 @@ if ((scr_get_multimode() == 2) && (strncasecmp(xpline, "/msay ", 6))) { // It isn't an /msay command scr_append_multiline(xpline); + g_free(xpline); return 0; } @@ -351,13 +356,13 @@ if (!curcmd) { scr_LogPrint(LPRINT_NORMAL, "Unrecognized command. " "Please see the manual for a list of known commands."); - if (xpline != line) g_free(xpline); + g_free(xpline); return 0; } if (!curcmd->func) { scr_LogPrint(LPRINT_NORMAL, "This functionality is not yet implemented, sorry."); - if (xpline != line) g_free(xpline); + g_free(xpline); return 0; } // Lets go to the command parameters @@ -368,7 +373,7 @@ p++; // Call command-specific function (*curcmd->func)(p); - if (xpline != line) g_free(xpline); + g_free(xpline); return 0; }