From 4f4c729547a7b116fa7da7c83128ee5a706351c5 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 9 Dec 2024 10:17:58 -0800 Subject: [PATCH] use manual pointer arithmetic to avoid invalid pointer cast --- include/boost/regex/v5/perl_matcher_non_recursive.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/regex/v5/perl_matcher_non_recursive.hpp b/include/boost/regex/v5/perl_matcher_non_recursive.hpp index 87400452..5a1c3f4c 100644 --- a/include/boost/regex/v5/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v5/perl_matcher_non_recursive.hpp @@ -237,8 +237,8 @@ void perl_matcher::extend_stack() saved_state* backup_state; stack_base = static_cast(get_mem_block()); backup_state = reinterpret_cast(reinterpret_cast(stack_base)+BOOST_REGEX_BLOCKSIZE); - saved_extra_block* block = static_cast(backup_state); - --block; + saved_extra_block* block = reinterpret_cast( + reinterpret_cast(backup_state) - sizeof(saved_extra_block)); (void) new (block) saved_extra_block(m_stack_base, m_backup_state); m_stack_base = stack_base; m_backup_state = block;