Backport ad7211df6f257e39da2e5a11b2456b4488f32a1e, see rhbz#1825593
This commit is contained in:
parent
0c8ce6b93d
commit
d933922e69
@ -0,0 +1,47 @@
|
|||||||
|
From ad7211df6f257e39da2e5a11b2456b4488f32a1e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oliver Bruns <obruns@gmail.com>
|
||||||
|
Date: Mon, 6 Apr 2020 10:38:30 +0200
|
||||||
|
Subject: [PATCH] [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
|
||||||
|
---
|
||||||
|
clang/lib/AST/RawCommentList.cpp | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
|
||||||
|
index 8552b4fcd2b..a8d15036cab 100644
|
||||||
|
--- a/clang/lib/AST/RawCommentList.cpp
|
||||||
|
+++ b/clang/lib/AST/RawCommentList.cpp
|
||||||
|
@@ -431,7 +431,7 @@ std::string RawComment::getFormattedText(const SourceManager &SourceMgr,
|
||||||
|
};
|
||||||
|
|
||||||
|
auto DropTrailingNewLines = [](std::string &Str) {
|
||||||
|
- while (Str.back() == '\n')
|
||||||
|
+ while (!Str.empty() && Str.back() == '\n')
|
||||||
|
Str.pop_back();
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.25.2
|
||||||
|
|
@ -4,7 +4,7 @@
|
|||||||
%global min_ver 0
|
%global min_ver 0
|
||||||
%global patch_ver 0
|
%global patch_ver 0
|
||||||
#%%global rc_ver 6
|
#%%global rc_ver 6
|
||||||
%global baserelease 1
|
%global baserelease 2
|
||||||
|
|
||||||
%global clang_tools_binaries \
|
%global clang_tools_binaries \
|
||||||
%{_bindir}/clang-apply-replacements \
|
%{_bindir}/clang-apply-replacements \
|
||||||
@ -98,6 +98,7 @@ Source4: https://prereleases.llvm.org/%{version}/hans-gpg-key.asc
|
|||||||
Patch4: 0002-gtest-reorg.patch
|
Patch4: 0002-gtest-reorg.patch
|
||||||
Patch11: 0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch
|
Patch11: 0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch
|
||||||
Patch13: 0001-Make-funwind-tables-the-default-for-all-archs.patch
|
Patch13: 0001-Make-funwind-tables-the-default-for-all-archs.patch
|
||||||
|
Patch14: 0001-clang-fix-undefined-behaviour-in-RawComment-getForma.patch
|
||||||
|
|
||||||
# Not Upstream
|
# Not Upstream
|
||||||
Patch15: 0001-clang-Don-t-install-static-libraries.patch
|
Patch15: 0001-clang-Don-t-install-static-libraries.patch
|
||||||
@ -250,6 +251,7 @@ pathfix.py -i %{__python3} -pn \
|
|||||||
%patch4 -p1 -b .gtest
|
%patch4 -p1 -b .gtest
|
||||||
%patch11 -p1 -b .libcxx-fix
|
%patch11 -p1 -b .libcxx-fix
|
||||||
%patch13 -p2 -b .unwind-all
|
%patch13 -p2 -b .unwind-all
|
||||||
|
%patch14 -p2 -b .clangd
|
||||||
%patch15 -p2 -b .no-install-static
|
%patch15 -p2 -b .no-install-static
|
||||||
|
|
||||||
mv ../%{clang_tools_srcdir} tools/extra
|
mv ../%{clang_tools_srcdir} tools/extra
|
||||||
@ -469,6 +471,9 @@ LD_LIBRARY_PATH=%{buildroot}%{_libdir} ninja check-all -C _build || \
|
|||||||
|
|
||||||
%endif
|
%endif
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue May 19 2020 sguelton@redhat.com - 10.0.0-2
|
||||||
|
- Backport ad7211df6f257e39da2e5a11b2456b4488f32a1e, see rhbz#1825593
|
||||||
|
|
||||||
* Thu Mar 26 2020 sguelton@redhat.com - 10.0.0-1
|
* Thu Mar 26 2020 sguelton@redhat.com - 10.0.0-1
|
||||||
- 10.0.0 final
|
- 10.0.0 final
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user