Ticket #2123: crash while copying into directory named "????"

1. create directory named "????" and enter into this directory
2. point at any file in other panel
3. press F5 and Enter
Segfault

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2010-07-07 14:01:15 +03:00
parent 3108909bb0
commit 973bbb70a2
2 changed files with 14 additions and 2 deletions

View File

@ -118,14 +118,25 @@ mc_search__translate_replace_glob_to_regex (gchar *str)
{
GString *buff = g_string_new ("");
int cnt = '0';
gboolean escaped_mode = FALSE;
while (*str) {
char c = *str++;
switch (c) {
case '\\':
if (!escaped_mode)
{
escaped_mode = TRUE;
continue;
}
break;
case '*':
case '?':
if (!escaped_mode)
{
g_string_append_c (buff, '\\');
c = ++cnt;
continue;
}
break;
/* breaks copying: mc uses "\0" internally, it must not be changed */
/*case '\\':*/
@ -134,6 +145,7 @@ mc_search__translate_replace_glob_to_regex (gchar *str)
break;
}
g_string_append_c (buff, c);
escaped_mode = FALSE;
}
return buff;
}

View File

@ -39,7 +39,7 @@
static const char ESCAPE_SHELL_CHARS[] = " !#$%()&{}[]`?|<>;*\\\"'";
static const char ESCAPE_REGEX_CHARS[] = "^!#$%()&{}[]`?|<>;*.\\";
static const char ESCAPE_GLOB_CHARS[] = "$*\\";
static const char ESCAPE_GLOB_CHARS[] = "$*\\?";
/*** file scope functions ************************************************************************/