Fix memory leak in SkPDFRasterizer

https://codereview.chromium.org/26373005/



git-svn-id: http://skia.googlecode.com/svn/trunk@11652 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2013-10-08 15:40:49 +00:00
parent 6187abe776
commit 25ae5eef33

View File

@ -21,11 +21,11 @@
bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output) {
size_t size = pdf->getLength();
void* buffer = sk_malloc_throw(size);
pdf->read(buffer, size);
SkAutoFree buffer(sk_malloc_throw(size));
pdf->read(buffer.get(), size);
SkAutoTDelete<poppler::document> doc(
poppler::document::load_from_raw_data((const char*)buffer, size));
poppler::document::load_from_raw_data((const char*)buffer.get(), size));
if (!doc.get() || doc->is_locked()) {
return false;
}
@ -45,7 +45,7 @@ bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
if (!bitmap.allocPixels()) {
return false;
return false;
}
bitmap.eraseColor(SK_ColorWHITE);
SkPMColor* bitmapPixels = (SkPMColor*)bitmap.getPixels();