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

Unified Diff: pdf/pdfium/fuzzers/pdfium_fuzzer.cc

Issue 1991103003: Fix memory leaks in the PDFium fuzzer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: pdf/pdfium/fuzzers/pdfium_fuzzer.cc
diff --git a/pdf/pdfium/fuzzers/pdfium_fuzzer.cc b/pdf/pdfium/fuzzers/pdfium_fuzzer.cc
index 2bb17c2f470452b4ddb184e5692f6621a92ccc70..b0d7b5de26c250081ce4da2df3a444d5bb3136b7 100644
--- a/pdf/pdfium/fuzzers/pdfium_fuzzer.cc
+++ b/pdf/pdfium/fuzzers/pdfium_fuzzer.cc
@@ -55,33 +55,31 @@ static bool RenderPage(const FPDF_DOCUMENT& doc,
const FPDF_FORMHANDLE& form,
const int page_index) {
FPDF_PAGE page = FPDF_LoadPage(doc, page_index);
- if (!page) {
+ if (!page)
return false;
- }
+
FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
FORM_OnAfterLoadPage(page, form);
FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN);
- double scale = 1.0;
+ const double scale = 1.0;
int width = static_cast<int>(FPDF_GetPageWidth(page) * scale);
int height = static_cast<int>(FPDF_GetPageHeight(page) * scale);
FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0);
- if (!bitmap) {
- return false;
- }
+ if (bitmap) {
+ FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF);
+ FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0);
- FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF);
- FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0);
+ FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0);
- FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0);
-
- FPDFBitmap_Destroy(bitmap);
+ FPDFBitmap_Destroy(bitmap);
+ }
FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_CLOSE);
FORM_OnBeforeClosePage(page, form);
FPDFText_ClosePage(text_page);
FPDF_ClosePage(page);
- return true;
+ return !!bitmap;
}
static void RenderPdf(const char* pBuf, size_t len) {
« 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