diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-01 23:07:59 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-01 23:07:59 +0000 |
commit | bd4a60ba13f08c4b88682344a37f5ebc0ceb1952 (patch) | |
tree | 698f240aa8f6c7394590db5412b7fa1dc01c8721 /chrome/renderer | |
parent | f38374f3cd28322208f71094ace8162299b0380d (diff) | |
download | chromium_src-bd4a60ba13f08c4b88682344a37f5ebc0ceb1952.zip chromium_src-bd4a60ba13f08c4b88682344a37f5ebc0ceb1952.tar.gz chromium_src-bd4a60ba13f08c4b88682344a37f5ebc0ceb1952.tar.bz2 |
Linux: Print a potential double free in PrintWebViewHelper::PrintPages().
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6598077
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76456 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/print_web_view_helper.h | 2 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper_linux.cc | 15 |
2 files changed, 7 insertions, 10 deletions
diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index dfe3e92..61d0a2f 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -99,7 +99,7 @@ class PrintWebViewHelper : public RenderViewObserver , const gfx::Size& canvas_size, WebKit::WebFrame* frame, printing::NativeMetafile* metafile, - skia::VectorCanvas** canvas); + scoped_ptr<skia::VectorCanvas>* canvas); #else void PrintPage(const ViewMsg_PrintPage_Params& params, const gfx::Size& canvas_size, diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc index 2722528..c4446d3 100644 --- a/chrome/renderer/print_web_view_helper_linux.cc +++ b/chrome/renderer/print_web_view_helper_linux.cc @@ -137,7 +137,7 @@ bool PrintWebViewHelper::RenderPages(const ViewMsg_PrintPages_Params& params, int* page_count, printing::NativeMetafile* metafile) { ViewMsg_Print_Params printParams = params.params; - skia::VectorCanvas* canvas = NULL; + scoped_ptr<skia::VectorCanvas> canvas; { // Hack - when |prep_frame_view| goes out of scope, PrintEnd() gets called. @@ -166,19 +166,16 @@ bool PrintWebViewHelper::RenderPages(const ViewMsg_PrintPages_Params& params, if (params.pages.empty()) { for (int i = 0; i < *page_count; ++i) { page_params.page_number = i; - delete canvas; PrintPage(page_params, canvas_size, frame, metafile, &canvas); } } else { for (size_t i = 0; i < params.pages.size(); ++i) { page_params.page_number = params.pages[i]; - delete canvas; PrintPage(page_params, canvas_size, frame, metafile, &canvas); } } } - delete canvas; metafile->Close(); return true; @@ -188,7 +185,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, const gfx::Size& canvas_size, WebFrame* frame, printing::NativeMetafile* metafile, - skia::VectorCanvas** canvas) { + scoped_ptr<skia::VectorCanvas>* canvas) { double content_width_in_points; double content_height_in_points; double margin_top_in_points; @@ -215,10 +212,10 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, if (!cairo_context) return; - *canvas = new skia::VectorCanvas(cairo_context, - canvas_size.width(), - canvas_size.height()); - frame->printPage(params.page_number, *canvas); + canvas->reset(new skia::VectorCanvas(cairo_context, + canvas_size.width(), + canvas_size.height())); + frame->printPage(params.page_number, canvas->get()); // TODO(myhuang): We should handle transformation for paper margins. // TODO(myhuang): We should render the header and the footer. |