fix alloc-dealloc-mismatch reported in ASAN

This commit is contained in:
bladchan 2022-09-04 14:33:29 +08:00 committed by Serge Lamikhov-Center
parent 5468d90e06
commit b996977925
2 changed files with 4 additions and 4 deletions

View File

@ -118,7 +118,7 @@ template <class T> class section_impl : public section
void set_data( const char* raw_data, Elf_Word size ) override
{
if ( get_type() != SHT_NOBITS ) {
data = std::unique_ptr<char>( new ( std::nothrow ) char[size] );
data = std::unique_ptr<char[]>( new ( std::nothrow ) char[size] );
if ( nullptr != data.get() && nullptr != raw_data ) {
data_size = size;
std::copy( raw_data, raw_data + size, data.get() );
@ -149,7 +149,7 @@ template <class T> class section_impl : public section
}
else {
data_size = 2 * ( data_size + size );
std::unique_ptr<char> new_data(
std::unique_ptr<char[]> new_data(
new ( std::nothrow ) char[data_size] );
if ( nullptr != new_data ) {
@ -270,7 +270,7 @@ template <class T> class section_impl : public section
T header = { 0 };
Elf_Half index = 0;
std::string name;
std::unique_ptr<char> data;
std::unique_ptr<char[]> data;
Elf_Word data_size = 0;
const endianess_convertor* convertor = nullptr;
const address_translator* translator = nullptr;

View File

@ -214,7 +214,7 @@ template <class T> class segment_impl : public segment
private:
T ph = { 0 };
Elf_Half index = 0;
std::unique_ptr<char> data;
std::unique_ptr<char[]> data;
std::vector<Elf_Half> sections;
const endianess_convertor* convertor = nullptr;
const address_translator* translator = nullptr;