From d5001438c80f46ab9a8d0fb22ee4047e3f09a61a Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 21 Aug 2021 16:13:55 +0200 Subject: [PATCH] Fixes #446 : buffer overread in Tooltip::insert_doxygen(), and added _GLIBCXX_ASSERTIONS to tests --- .gitlab-ci.yml | 2 +- src/tooltips.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ea6a46..8cc55df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ stages: stage: test script: - mkdir build && cd build - - CXXFLAGS=-Werror cmake -DBUILD_TESTING=1 .. + - CXXFLAGS="-Werror -D_GLIBCXX_ASSERTIONS" cmake -DBUILD_TESTING=1 .. - make -j$(nproc) - broadwayd & CTEST_OUTPUT_ON_FAILURE=1 make test diff --git a/src/tooltips.cpp b/src/tooltips.cpp index baa604f..30acc68 100644 --- a/src/tooltips.cpp +++ b/src/tooltips.cpp @@ -1311,9 +1311,11 @@ void Tooltip::insert_doxygen(const std::string &input_, bool remove_delimiters) } else { auto i2 = i_saved; - --i2; - while(i2 > 0 && (input[i2] == ' ' || input[i2] == '\t')) + if(i2 > 0) { --i2; + while(i2 > 0 && (input[i2] == ' ' || input[i2] == '\t')) + --i2; + } if(input[i2] == '\n' || i2 == 0) markdown += "\n\n"; if(input[i_saved] == '\\')