Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: src/utils/SkPDFRasterizer.cpp

Issue 26373005: Fix memory leak in SkPDFRasterizer (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: switched to using SkAutoFree Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkPDFRasterizer.cpp
===================================================================
--- src/utils/SkPDFRasterizer.cpp (revision 11645)
+++ src/utils/SkPDFRasterizer.cpp (working copy)
@@ -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 @@
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698