Fix memleak in CapturePix (#1762)
This commit is contained in:
parent
f95851a767
commit
af50ed7302
1 changed files with 3 additions and 4 deletions
|
|
@ -116,16 +116,15 @@ static BYTE *CaptureEnc(BYTE *src, BYTE *dst, int width)
|
|||
static bool CapturePix(const CelOutputBuffer &buf, std::ofstream *out)
|
||||
{
|
||||
int width = buf.w();
|
||||
BYTE *pBuffer = (BYTE *)DiabloAllocPtr(2 * width);
|
||||
auto pBuffer = std::make_unique<BYTE[]>(2 * width);
|
||||
BYTE *pixels = buf.begin();
|
||||
for (int height = buf.h(); height > 0; height--) {
|
||||
const BYTE *pBufferEnd = CaptureEnc(pixels, pBuffer, width);
|
||||
const BYTE *pBufferEnd = CaptureEnc(pixels, pBuffer.get(), width);
|
||||
pixels += buf.pitch();
|
||||
out->write(reinterpret_cast<const char *>(pBuffer), pBufferEnd - pBuffer);
|
||||
out->write(reinterpret_cast<const char *>(pBuffer.get()), pBufferEnd - pBuffer.get());
|
||||
if (out->fail())
|
||||
return false;
|
||||
}
|
||||
mem_free_dbg(pBuffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue