diff --git a/elfio/elfio_section.hpp b/elfio/elfio_section.hpp index f08b585..4be0b97 100644 --- a/elfio/elfio_section.hpp +++ b/elfio/elfio_section.hpp @@ -285,7 +285,7 @@ template class section_impl : public section Elf_Xword size = get_size(); if ( nullptr == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() && - ( sh_offset + size ) <= get_stream_size() ) { + sh_offset <= get_stream_size() && size <= (get_stream_size() - sh_offset)) { data.reset( new ( std::nothrow ) char[size_t( size ) + 1] ); if ( ( 0 != size ) && ( nullptr != data ) ) {