Ai
1 Star 0 Fork 40

hefq343/boost_1

forked from src-openEuler/boost
关闭
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
boost-1.78-locale-Fix-access-to-first-element-of-empty-vector.patch 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
sdlzx 提交于 2021-12-12 11:53 +08:00 . Update to 1.78.0
From 1ff0ead837b32b9415dc840dfef6549e8754b98d Mon Sep 17 00:00:00 2001
From: Alexander Grund <Flamefire@users.noreply.github.com>
Date: Fri, 10 Dec 2021 17:53:01 +0100
Subject: [PATCH] Fix access to first element of empty vector
Trying to access tmp[0] causes a crash on Fedora when assertion on STL
are enabled.
/usr/include/c++/10/bits/stl_vector.h:1045: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc>::reference = unsigned char&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n < this->size(), true)' failed.
Fix is to never have an empty vector as ICU sort keys include the NULL
terminator, hence we need at least `length + 1` bytes which means the
vector has at least 1 element: The NULL terminator
---
src/icu/collator.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/locale/src/icu/collator.cpp b/libs/locale/src/icu/collator.cpp
index 7f1ea6ae..79668aa6 100644
--- a/libs/locale/src/icu/collator.cpp
+++ b/libs/locale/src/icu/collator.cpp
@@ -91,9 +91,9 @@ namespace boost {
{
icu::UnicodeString str=cvt_.icu(b,e);
std::vector<uint8_t> tmp;
- tmp.resize(str.length());
+ tmp.resize(str.length() + 1u);
icu::Collator *collate = get_collator(level);
- int len = collate->getSortKey(str,&tmp[0],tmp.size());
+ const int len = collate->getSortKey(str,&tmp[0],tmp.size());
if(len > int(tmp.size())) {
tmp.resize(len);
collate->getSortKey(str,&tmp[0],tmp.size());
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hefq343/boost_1.git
git@gitee.com:hefq343/boost_1.git
hefq343
boost_1
boost_1
openEuler-22.03-LTS-SP4

搜索帮助