From 5c7d018d44b9f5767208789f9e8a6db764b743a9 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Tue, 20 Oct 2015 14:29:03 +0530 Subject: [PATCH 1/2] Check if f is valid before dereference file = f at line no 228. file is checked against NULL at 232, but f is not checked. Adding null check. --- include/boost/regex/v4/fileiter.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/regex/v4/fileiter.hpp b/include/boost/regex/v4/fileiter.hpp index f13c4b2fb..4f7e4fe80 100644 --- a/include/boost/regex/v4/fileiter.hpp +++ b/include/boost/regex/v4/fileiter.hpp @@ -226,7 +226,8 @@ class BOOST_REGEX_DECL mapfile_iterator mapfile_iterator(const mapfile* f, long arg_position) { file = f; - node = f->_first + arg_position / mapfile::buf_size; + if(f) + node = f->_first + arg_position / mapfile::buf_size; offset = arg_position % mapfile::buf_size; if(file) file->lock(node); From 60698afce9ae24aa20e35dda551cd7205c968bf7 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Sat, 24 Oct 2015 08:55:03 +0530 Subject: [PATCH 2/2] Update fileiter.hpp --- include/boost/regex/v4/fileiter.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/boost/regex/v4/fileiter.hpp b/include/boost/regex/v4/fileiter.hpp index 4f7e4fe80..0ecb16bee 100644 --- a/include/boost/regex/v4/fileiter.hpp +++ b/include/boost/regex/v4/fileiter.hpp @@ -225,12 +225,11 @@ class BOOST_REGEX_DECL mapfile_iterator mapfile_iterator() { node = 0; file = 0; offset = 0; } mapfile_iterator(const mapfile* f, long arg_position) { + BOOST_ASSERT(f); file = f; - if(f) - node = f->_first + arg_position / mapfile::buf_size; + node = f->_first + arg_position / mapfile::buf_size; offset = arg_position % mapfile::buf_size; - if(file) - file->lock(node); + file->lock(node); } mapfile_iterator(const mapfile_iterator& i) {