Renamed MemBuffer::free() to dealloc() in order to better support
malloc debugging libraries like mpatrol. committer: mfx <mfx> 983109777 +0000
This commit is contained in:
+5
-5
@@ -348,31 +348,31 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
|
|||||||
#define UPX_MIN3(a,b,c) ((a) <= (b) ? UPX_MIN(a,c) : UPX_MIN(b,c))
|
#define UPX_MIN3(a,b,c) ((a) <= (b) ? UPX_MIN(a,c) : UPX_MIN(b,c))
|
||||||
|
|
||||||
|
|
||||||
#if 0 && defined(__cplusplus)
|
#if 0 && defined(__cplusplus) && !defined(new) && !defined(delete)
|
||||||
// global operators - debug
|
// global operators - debug
|
||||||
inline void *operator new(size_t l)
|
inline void *operator new(size_t l)
|
||||||
{
|
{
|
||||||
void *p = malloc(l);
|
void *p = malloc(l);
|
||||||
printf("new %6ld %p\n",(long)l,p);
|
printf("new %6ld %p\n",(long)l,p);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
inline void *operator new[](size_t l)
|
inline void *operator new[](size_t l)
|
||||||
{
|
{
|
||||||
void *p = malloc(l);
|
void *p = malloc(l);
|
||||||
printf("new %6ld %p\n",(long)l,p);
|
printf("new[] %6ld %p\n",(long)l,p);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
inline void operator delete(void *p)
|
inline void operator delete(void *p)
|
||||||
{
|
{
|
||||||
printf("delete %p\n",p);
|
printf("delete %p\n",p);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (p) free(p);
|
if (p) free(p);
|
||||||
}
|
}
|
||||||
inline void operator delete[](void *p)
|
inline void operator delete[](void *p)
|
||||||
{
|
{
|
||||||
printf("delete %p\n",p);
|
printf("delete[] %p\n",p);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (p) free(p);
|
if (p) free(p);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -44,10 +44,10 @@ MemBuffer::MemBuffer(unsigned size) :
|
|||||||
|
|
||||||
MemBuffer::~MemBuffer()
|
MemBuffer::~MemBuffer()
|
||||||
{
|
{
|
||||||
this->free();
|
this->dealloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemBuffer::free()
|
void MemBuffer::dealloc()
|
||||||
{
|
{
|
||||||
if (alloc_ptr)
|
if (alloc_ptr)
|
||||||
::free(alloc_ptr);
|
::free(alloc_ptr);
|
||||||
@@ -69,7 +69,7 @@ unsigned MemBuffer::getSize() const
|
|||||||
void MemBuffer::alloc(unsigned size, unsigned base_offset)
|
void MemBuffer::alloc(unsigned size, unsigned base_offset)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
this->free();
|
this->dealloc();
|
||||||
#else
|
#else
|
||||||
// don't automaticlly free a used buffer
|
// don't automaticlly free a used buffer
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
void allocForCompression(unsigned uncompressed_size);
|
void allocForCompression(unsigned uncompressed_size);
|
||||||
void allocForUncompression(unsigned uncompressed_size);
|
void allocForUncompression(unsigned uncompressed_size);
|
||||||
|
|
||||||
void free();
|
void dealloc();
|
||||||
|
|
||||||
const unsigned char *getBuf() const { return ptr; }
|
const unsigned char *getBuf() const { return ptr; }
|
||||||
unsigned getSize() const;
|
unsigned getSize() const;
|
||||||
@@ -66,10 +66,14 @@ private:
|
|||||||
MemBuffer& operator= (MemBuffer const &); // { return *this; }
|
MemBuffer& operator= (MemBuffer const &); // { return *this; }
|
||||||
|
|
||||||
// disable dynamic allocation
|
// disable dynamic allocation
|
||||||
|
#ifndef new
|
||||||
static void *operator new (size_t); // {}
|
static void *operator new (size_t); // {}
|
||||||
static void *operator new[] (size_t); // {}
|
static void *operator new[] (size_t); // {}
|
||||||
|
#endif
|
||||||
|
#ifndef delete
|
||||||
//static void operator delete (void *) {}
|
//static void operator delete (void *) {}
|
||||||
//static void operator delete[] (void *) {}
|
//static void operator delete[] (void *) {}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* already included */
|
#endif /* already included */
|
||||||
|
|||||||
+2
-2
@@ -186,7 +186,7 @@ int PackVmlinuzI386::decompressKernel()
|
|||||||
break;
|
break;
|
||||||
// realloc and try again
|
// realloc and try again
|
||||||
unsigned s = ibuf.getSize();
|
unsigned s = ibuf.getSize();
|
||||||
ibuf.free();
|
ibuf.dealloc();
|
||||||
ibuf.alloc(3 * s / 2);
|
ibuf.alloc(3 * s / 2);
|
||||||
}
|
}
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
@@ -232,7 +232,7 @@ void PackVmlinuzI386::readKernel()
|
|||||||
memcpy(setup_buf, obuf, setup_size);
|
memcpy(setup_buf, obuf, setup_size);
|
||||||
//OutputFile::dump("setup.img", setup_buf, setup_size);
|
//OutputFile::dump("setup.img", setup_buf, setup_size);
|
||||||
|
|
||||||
obuf.free();
|
obuf.dealloc();
|
||||||
obuf.allocForCompression(klen);
|
obuf.allocForCompression(klen);
|
||||||
|
|
||||||
ph.u_len = klen;
|
ph.u_len = klen;
|
||||||
|
|||||||
+4
-4
@@ -2155,7 +2155,7 @@ void PackW32Pe::rebuildRelocs(upx_byte *& extrainfo)
|
|||||||
else
|
else
|
||||||
memcpy (obuf + ODADDR(PEDIR_RELOC) - rvamin,oxrelocs,soxrelocs);
|
memcpy (obuf + ODADDR(PEDIR_RELOC) - rvamin,oxrelocs,soxrelocs);
|
||||||
delete [] oxrelocs; oxrelocs = NULL;
|
delete [] oxrelocs; oxrelocs = NULL;
|
||||||
wrkmem.free();
|
wrkmem.dealloc();
|
||||||
|
|
||||||
ODSIZE(PEDIR_RELOC) = soxrelocs;
|
ODSIZE(PEDIR_RELOC) = soxrelocs;
|
||||||
}
|
}
|
||||||
@@ -2236,7 +2236,7 @@ void PackW32Pe::unpack(OutputFile *fo)
|
|||||||
extrainfo += sizeof(pe_section_t) * objs;
|
extrainfo += sizeof(pe_section_t) * objs;
|
||||||
|
|
||||||
// read the noncompressed section
|
// read the noncompressed section
|
||||||
ibuf.free();
|
ibuf.dealloc();
|
||||||
ibuf.alloc(isection[2].size);
|
ibuf.alloc(isection[2].size);
|
||||||
fi->seek(isection[2].rawdataptr,SEEK_SET);
|
fi->seek(isection[2].rawdataptr,SEEK_SET);
|
||||||
fi->readx(ibuf,isection[2].size);
|
fi->readx(ibuf,isection[2].size);
|
||||||
@@ -2284,7 +2284,7 @@ void PackW32Pe::unpack(OutputFile *fo)
|
|||||||
// write decompressed file
|
// write decompressed file
|
||||||
if (fo)
|
if (fo)
|
||||||
{
|
{
|
||||||
ibuf.free();
|
ibuf.dealloc();
|
||||||
ibuf.alloc(osection[0].rawdataptr);
|
ibuf.alloc(osection[0].rawdataptr);
|
||||||
memset(ibuf,0,osection[0].rawdataptr);
|
memset(ibuf,0,osection[0].rawdataptr);
|
||||||
infoHeader("[Writing uncompressed file]");
|
infoHeader("[Writing uncompressed file]");
|
||||||
@@ -2298,7 +2298,7 @@ void PackW32Pe::unpack(OutputFile *fo)
|
|||||||
fo->write(obuf + osection[ic].vaddr - rvamin,ALIGN_UP(osection[ic].size,oh.filealign));
|
fo->write(obuf + osection[ic].vaddr - rvamin,ALIGN_UP(osection[ic].size,oh.filealign));
|
||||||
copyOverlay(fo, overlay, &obuf);
|
copyOverlay(fo, overlay, &obuf);
|
||||||
}
|
}
|
||||||
ibuf.free();
|
ibuf.dealloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+5
-5
@@ -432,7 +432,7 @@ void PackWcle::encodeImage(const Filter *ft)
|
|||||||
ph.overlap_overhead = findOverlapOverhead(oimage+RESERVED, 512);
|
ph.overlap_overhead = findOverlapOverhead(oimage+RESERVED, 512);
|
||||||
buildLoader(ft);
|
buildLoader(ft);
|
||||||
|
|
||||||
ibuf.free();
|
ibuf.dealloc();
|
||||||
soimage = (ph.c_len + 3) &~ 3;
|
soimage = (ph.c_len + 3) &~ 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ void PackWcle::pack(OutputFile *fo)
|
|||||||
ifixups[sofixups++] = (unsigned char) ih.automatic_data_object;
|
ifixups[sofixups++] = (unsigned char) ih.automatic_data_object;
|
||||||
unsigned ic = objects*sizeof(*iobject_table);
|
unsigned ic = objects*sizeof(*iobject_table);
|
||||||
memcpy(ifixups+sofixups,iobject_desc,ic);
|
memcpy(ifixups+sofixups,iobject_desc,ic);
|
||||||
iobject_desc.free();
|
iobject_desc.dealloc();
|
||||||
|
|
||||||
sofixups += ic;
|
sofixups += ic;
|
||||||
set_le32(ifixups+sofixups,ih.init_esp_offset+IOT(ih.init_ss_object-1,my_base_address)); // old stack pointer
|
set_le32(ifixups+sofixups,ih.init_esp_offset+IOT(ih.init_ss_object-1,my_base_address)); // old stack pointer
|
||||||
@@ -566,7 +566,7 @@ void PackWcle::decodeFixups()
|
|||||||
{
|
{
|
||||||
upx_byte *p = oimage + soimage;
|
upx_byte *p = oimage + soimage;
|
||||||
|
|
||||||
iimage.free();
|
iimage.dealloc();
|
||||||
|
|
||||||
MemBuffer tmpbuf;
|
MemBuffer tmpbuf;
|
||||||
unsigned fixupn = unoptimizeReloc32(&p,oimage,&tmpbuf,1);
|
unsigned fixupn = unoptimizeReloc32(&p,oimage,&tmpbuf,1);
|
||||||
@@ -584,7 +584,7 @@ void PackWcle::decodeFixups()
|
|||||||
set_le32(oimage+jc,r);
|
set_le32(oimage+jc,r);
|
||||||
}
|
}
|
||||||
set_le32(wrkmem+ic*8,0xFFFFFFFF); // end of 32-bit offset fixups
|
set_le32(wrkmem+ic*8,0xFFFFFFFF); // end of 32-bit offset fixups
|
||||||
tmpbuf.free();
|
tmpbuf.dealloc();
|
||||||
|
|
||||||
// selector fixups and self-relative fixups
|
// selector fixups and self-relative fixups
|
||||||
const upx_byte *selector_fixups = p;
|
const upx_byte *selector_fixups = p;
|
||||||
@@ -788,7 +788,7 @@ void PackWcle::unpack(OutputFile *fo)
|
|||||||
handleStub(fo);
|
handleStub(fo);
|
||||||
|
|
||||||
readObjectTable();
|
readObjectTable();
|
||||||
iobject_desc.free();
|
iobject_desc.dealloc();
|
||||||
readPageMap();
|
readPageMap();
|
||||||
readResidentNames();
|
readResidentNames();
|
||||||
readEntryTable();
|
readEntryTable();
|
||||||
|
|||||||
Reference in New Issue
Block a user