sync upstream bugfix and enable unit test
(cherry picked from commit 2c9b70670a49b2c39d12d3d1c42ae3e597d27e96)
This commit is contained in:
parent
fdce4a1ab6
commit
226c6767cb
34
backport-Fix-segfaults-on-allocation-failure.patch
Normal file
34
backport-Fix-segfaults-on-allocation-failure.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From 7d644e7ba27eaadda753febf0b142faa9affbbca Mon Sep 17 00:00:00 2001
|
||||
From: hongyang7 <yang.a.hong@intel.com>
|
||||
Date: Thu, 16 Dec 2021 19:02:17 +0800
|
||||
Subject: [PATCH] Fix segfaults on allocation failure (#4)
|
||||
|
||||
Throw std::bad_alloc instead of returning nullptr from
|
||||
ue2::AlignedAllocator. Allocators for STL containers are expected never
|
||||
to return with an invalid pointer, and instead must throw on failure.
|
||||
Violating this expectation can lead to invalid pointer dereferences.
|
||||
|
||||
Co-authored-by: johanngan <johanngan.us@gmail.com>
|
||||
|
||||
fixes github issue #317 (PR #320)
|
||||
---
|
||||
src/util/alloc.h | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/util/alloc.h b/src/util/alloc.h
|
||||
index de20c8d02..49b4a824d 100644
|
||||
--- a/src/util/alloc.h
|
||||
+++ b/src/util/alloc.h
|
||||
@@ -76,7 +76,11 @@ class AlignedAllocator {
|
||||
|
||||
T *allocate(std::size_t size) const {
|
||||
size_t alloc_size = size * sizeof(T);
|
||||
- return static_cast<T *>(aligned_malloc_internal(alloc_size, N));
|
||||
+ T *ptr = static_cast<T *>(aligned_malloc_internal(alloc_size, N));
|
||||
+ if (!ptr) {
|
||||
+ throw std::bad_alloc();
|
||||
+ }
|
||||
+ return ptr;
|
||||
}
|
||||
|
||||
void deallocate(T *x, std::size_t) const noexcept {
|
||||
@ -1,6 +1,6 @@
|
||||
Name: hyperscan
|
||||
Version: 5.4.0
|
||||
Release: 1
|
||||
Release: 2
|
||||
Summary: High-performance regular expression matching library
|
||||
|
||||
License: BSD
|
||||
@ -10,6 +10,8 @@ Source0: https://github.com/intel/%{name}/archive/v%{version}.tar.gz#/%{name}-%{
|
||||
Patch0: hyperscan-aarch64-support.patch
|
||||
Patch1: Fix-build-error-on-x86_64.patch
|
||||
Patch2: Fix-hyperscan-gcc10.patch
|
||||
# https://github.com/intel/hyperscan/commit/7d644e7ba27eaadda753febf0b142faa9affbbca
|
||||
Patch3: backport-Fix-segfaults-on-allocation-failure.patch
|
||||
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: boost-devel
|
||||
@ -61,6 +63,9 @@ needed for developing Hyperscan applications.
|
||||
%install
|
||||
%make_install
|
||||
|
||||
%check
|
||||
./bin/unit-hyperscan
|
||||
|
||||
%files
|
||||
%doc %{_defaultdocdir}/%{name}/examples/README.md
|
||||
%doc %{_defaultdocdir}/%{name}/examples/*.cc
|
||||
@ -75,6 +80,9 @@ needed for developing Hyperscan applications.
|
||||
%{_includedir}/hs/
|
||||
|
||||
%changelog
|
||||
* Thu Oct 20 2022 Liu Zixian <liuzixian4@huawei.com> - 5.4.0-2
|
||||
- Sync upstream bugfix and enable regression test
|
||||
|
||||
* Wed Oct 06 2021 sdlzx <hdu_sdlzx@163.com> - 5.4.0-1
|
||||
- Update to 5.4.0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user