From 6c034985a29a0c8bc1b4c24a21bcfa37b30e7d7a Mon Sep 17 00:00:00 2001 From: AngryGamer Date: Tue, 2 Jul 2019 03:32:50 -0700 Subject: [PATCH] Fix crash when sorting out_of_range columns Fix crash while sorting the right part of equal sign with column-selection: 100/20 = 5 1/3 = 0.333 22/7 = 3.14285714286 Note that empty lines between the numbers are intentional. Fix #5865, fix #3391, close #3771 --- PowerEditor/src/MISC/Common/Sorters.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PowerEditor/src/MISC/Common/Sorters.h b/PowerEditor/src/MISC/Common/Sorters.h index 365192d5..144e8c20 100644 --- a/PowerEditor/src/MISC/Common/Sorters.h +++ b/PowerEditor/src/MISC/Common/Sorters.h @@ -48,6 +48,12 @@ protected: { if (isSortingSpecificColumns()) { + // prevent an std::out_of_range exception + if (input.length() < _fromColumn) + { + return TEXT(""); + } + return input.substr(_fromColumn, 1 + _toColumn - _fromColumn); } else