From 65fe0a1a2cbe28daa328faa0edb559b525d97480 Mon Sep 17 00:00:00 2001 From: Alex P Date: Thu, 25 May 2023 17:58:42 +0300 Subject: [PATCH] null offset check --- include/neutx/container/detail/flat_data_store.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/neutx/container/detail/flat_data_store.hpp b/include/neutx/container/detail/flat_data_store.hpp index 4af01b4..c9f0a00 100644 --- a/include/neutx/container/detail/flat_data_store.hpp +++ b/include/neutx/container/detail/flat_data_store.hpp @@ -49,6 +49,9 @@ class flat_data_store { // convert abstract pointer to native pointer template T *native_pointer(pointer_t a_ptr) const { + if (!a_ptr) + return (T*)((char *)0); + if (a_ptr > m_size - sizeof(T)) throw std::invalid_argument("flat_data_store: bad offset"); return (T*)((char *)m_start + a_ptr);