Browse Source

Fix memleak in CapturePix (#1762)

pull/1775/head
Vladimir Olteanu 5 years ago committed by GitHub
parent
commit
af50ed7302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      Source/capture.cpp

7
Source/capture.cpp

@ -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…
Cancel
Save