Skip to content
Snippets Groups Projects
Commit 812f7299 authored by Tim Strazzere's avatar Tim Strazzere Committed by Serge Lamikhov-Center
Browse files

Avoid SIGABRT due to over allocating during new instance of objects.

parent 69b6177b
No related branches found
No related tags found
No related merge requests found
......@@ -147,7 +147,11 @@ class section_impl : public section
{
if ( get_type() != SHT_NOBITS ) {
delete [] data;
data = new char[size];
try {
data = new char[size];
} catch (const std::bad_alloc&) {
data_size = 0;
}
if ( 0 != data && 0 != raw_data ) {
data_size = size;
std::copy( raw_data, raw_data + size, data );
......@@ -174,7 +178,12 @@ class section_impl : public section
}
else {
data_size = 2*( data_size + size);
char* new_data = new char[data_size];
char* new_data;
try {
new_data = new char[data_size];
} catch (const std::bad_alloc&) {
new_data = 0;
}
if ( 0 != new_data ) {
std::copy( data, data + get_size(), new_data );
std::copy( raw_data, raw_data + size, new_data + get_size() );
......@@ -216,7 +225,11 @@ class section_impl : public section
Elf_Xword size = get_size();
if ( 0 == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() ) {
data = new char[size];
try {
data = new char[size];
} catch (const std::bad_alloc&) {
data_size = 0;
}
if ( 0 != size ) {
stream.seekg( (*convertor)( header.sh_offset ) );
stream.read( data, size );
......
......@@ -183,7 +183,11 @@ class segment_impl : public segment
if ( PT_NULL != get_type() && 0 != get_file_size() ) {
stream.seekg( (*convertor)( ph.p_offset ) );
Elf_Xword size = get_file_size();
data = new char[size];
try {
data = new char[size];
} catch (const std::bad_alloc&) {
data = 0;
}
if ( 0 != data ) {
stream.read( data, size );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment