[all-commits] [llvm/llvm-project] ad7211: [clang] fix undefined behaviour in RawComment::get...

Oliver Bruns via All-commits all-commits at lists.llvm.org
Mon Apr 6 01:48:51 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: ad7211df6f257e39da2e5a11b2456b4488f32a1e
      https://github.com/llvm/llvm-project/commit/ad7211df6f257e39da2e5a11b2456b4488f32a1e
  Author: Oliver Bruns <obruns at gmail.com>
  Date:   2020-04-06 (Mon, 06 Apr 2020)

  Changed paths:
    M clang/lib/AST/RawCommentList.cpp

  Log Message:
  -----------
  [clang] fix undefined behaviour in RawComment::getFormattedText()

Summary:
Calling `back()` and `pop_back()` on the empty string is undefined
behavior [1,2].

The issue manifested itself as an uncaught `std::out_of_range` exception
when running `clangd` compiled on RHEL7 using devtoolset-9.

[1] https://en.cppreference.com/w/cpp/string/basic_string/back
[2] https://en.cppreference.com/w/cpp/string/basic_string/pop_back

Fixes: 1ff7c32fc91c607b690d4bb9cf42f406be8dde68

Reviewers: teemperor, ioeric, cfe-commits

Reviewed By: teemperor

Subscribers: ilya-biryukov, kadircet, usaxena95

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77468




More information about the All-commits mailing list