1 Star 0 Fork 21

ultra_planet/aspell

forked from src-openEuler/aspell 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
aspell-0.60.6.1-fix-back-on-empty-vector.patch 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
fun_yang 提交于 2019-11-29 15:21 +08:00 . package init
From c6755a399e8a31cbee5129dde5124f9c54a47ab6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
Date: Wed, 4 Apr 2018 14:58:03 +0200
Subject: [PATCH] Do not call back() on an empty vector
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Calling std::vector::back() on an empty container is undefined.
Avoid doing that, simply return pointer to the beginning in case
the vector is empty.
Signed-off-by: Nikola Forró <nforro@redhat.com>
---
common/vector.hpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/common/vector.hpp b/common/vector.hpp
index 782e4b0..cb344bd 100644
--- a/common/vector.hpp
+++ b/common/vector.hpp
@@ -36,13 +36,13 @@ namespace acommon
}
T * data() {return &*this->begin();}
T * data(int pos) {return &*this->begin() + pos;}
- T * data_end() {return &this->back()+1;}
+ T * data_end() {return this->empty() ? &*this->begin() : &this->back()+1;}
T * pbegin() {return &*this->begin();}
- T * pend() {return &this->back()+1;}
+ T * pend() {return this->empty() ? &*this->begin() : &this->back()+1;}
const T * pbegin() const {return &*this->begin();}
- const T * pend() const {return &this->back()+1;}
+ const T * pend() const {return this->empty() ? &*this->begin() : &this->back()+1;}
template <typename U>
U * datap() {
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ultra_planet/aspell.git
git@gitee.com:ultra_planet/aspell.git
ultra_planet
aspell
aspell
master

搜索帮助