summaryrefslogtreecommitdiffstats
path: root/Source/cmRST.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-04-05 12:13:43 (GMT)
committerBrad King <brad.king@kitware.com>2019-04-05 12:18:14 (GMT)
commita9b38a17571bca0801594adf85fef59fac51d6ba (patch)
tree590dbf43ed1e15e7c654b3cd083f83e83dfb1381 /Source/cmRST.cxx
parent2024327746747989f47dec3859e2ca4bc66267c3 (diff)
downloadCMake-a9b38a17571bca0801594adf85fef59fac51d6ba.zip
CMake-a9b38a17571bca0801594adf85fef59fac51d6ba.tar.gz
CMake-a9b38a17571bca0801594adf85fef59fac51d6ba.tar.bz2
cmRST: Fix crash on empty markup block
Diffstat (limited to 'Source/cmRST.cxx')
-rw-r--r--Source/cmRST.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index b7216b0..2064275 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -457,6 +457,12 @@ void cmRST::UnindentLines(std::vector<std::string>& lines)
size_t trailingEmpty =
std::distance(rit, cmFindNot(cmReverseRange(lines), std::string()));
+ if ((leadingEmpty + trailingEmpty) >= lines.size()) {
+ // All lines are empty. The markup block is empty. Leave only one.
+ lines.resize(1);
+ return;
+ }
+
std::vector<std::string>::iterator contentEnd = cmRotate(
lines.begin(), lines.begin() + leadingEmpty, lines.end() - trailingEmpty);
lines.erase(contentEnd, lines.end());