Skip to content

Commit

Permalink
FileList::SetSortMode() - было чтение памяти за пределами массива.
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Sep 2, 2017
1 parent c066bd4 commit 34ad8f6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
shmuel 02.09.2017 20:34:02 +0200 - build 5022

1. FileList::SetSortMode() - было чтение памяти за пределами массива.

drkns 02.09.2017 16:16:24 +0100 - build 5021

1. Уточнение 5020.1.
Expand Down
57 changes: 30 additions & 27 deletions far/filelist.cpp
Expand Up @@ -3338,35 +3338,38 @@ void FileList::ApplySortMode(panel_sort Mode)

void FileList::SetSortMode(panel_sort Mode, bool KeepOrder)
{
if (!KeepOrder)
{
static bool InvertByDefault[] =
{
false, // UNSORTED,
false, // BY_NAME,
false, // BY_EXT,
true, // BY_MTIME,
true, // BY_CTIME,
true, // BY_ATIME,
true, // BY_SIZE,
false, // BY_DIZ,
false, // BY_OWNER,
true, // BY_COMPRESSEDSIZE,
true, // BY_NUMLINKS,
true, // BY_NUMSTREAMS,
true, // BY_STREAMSSIZE,
false, // BY_FULLNAME,
true, // BY_CHTIME,
false // BY_CUSTOMDATA,
};
static_assert(std::size(InvertByDefault) == static_cast<size_t>(panel_sort::COUNT));
if (Mode < panel_sort::COUNT)
{
if (!KeepOrder)
{
static bool InvertByDefault[] =
{
false, // UNSORTED,
false, // BY_NAME,
false, // BY_EXT,
true, // BY_MTIME,
true, // BY_CTIME,
true, // BY_ATIME,
true, // BY_SIZE,
false, // BY_DIZ,
false, // BY_OWNER,
true, // BY_COMPRESSEDSIZE,
true, // BY_NUMLINKS,
true, // BY_NUMSTREAMS,
true, // BY_STREAMSSIZE,
false, // BY_FULLNAME,
true, // BY_CHTIME,
false // BY_CUSTOMDATA,
};
static_assert(std::size(InvertByDefault) == static_cast<size_t>(panel_sort::COUNT));

assert(Mode < panel_sort::COUNT);
m_ReverseSortOrder = (m_SortMode == Mode && Global->Opt->ReverseSort)? !m_ReverseSortOrder : InvertByDefault[static_cast<size_t>(Mode)];
}

m_ReverseSortOrder = (m_SortMode == Mode && Global->Opt->ReverseSort)? !m_ReverseSortOrder : InvertByDefault[static_cast<size_t>(Mode)];
ApplySortMode(Mode);
}

ApplySortMode(Mode);
else
SetCustomSortMode(static_cast<int>(Mode), (KeepOrder ? SO_KEEPCURRENT : SO_AUTO), false);
}

void FileList::SetCustomSortMode(int Mode, sort_order Order, bool InvertByDefault)
Expand Down Expand Up @@ -7628,7 +7631,7 @@ void FileList::ShowFileList(bool Fast)
SetColor(COL_PANELCOLUMNTITLE);

string Indicators;

//if (GetSelectedFirstMode())
Indicators.push_back(L'^');

Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,5021)m4_dnl
m4_define(BUILD,5022)m4_dnl

0 comments on commit 34ad8f6

Please sign in to comment.