mirror of
https://github.com/serge1/ELFIO.git
synced 2024-12-27 12:17:28 +00:00
Prevent potential dereferencing of NULL pointer
This commit is contained in:
parent
858b7a3b70
commit
cdafaa0abf
@ -251,10 +251,10 @@ class section_impl : public section
|
||||
data_size = 0;
|
||||
}
|
||||
|
||||
if ( 0 != size ) {
|
||||
if ( ( 0 != size ) && ( 0 != data ) ) {
|
||||
stream.seekg( (*convertor)( header.sh_offset ) );
|
||||
stream.read( data, size );
|
||||
data[size] = 0; //ensure data is ended with 0 to avoid oob read
|
||||
data[size] = 0; // Ensure data is ended with 0 to avoid oob read
|
||||
data_size = size;
|
||||
}
|
||||
}
|
||||
|
@ -69,11 +69,10 @@ class segment_impl : public segment
|
||||
public:
|
||||
//------------------------------------------------------------------------------
|
||||
segment_impl( endianess_convertor* convertor_ ) :
|
||||
convertor( convertor_ )
|
||||
convertor( convertor_ ), stream_size( 0 ), index( 0 ), data( 0 )
|
||||
{
|
||||
is_offset_set = false;
|
||||
std::fill_n( reinterpret_cast<char*>( &ph ), sizeof( ph ), '\0' );
|
||||
data = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user