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

Side by Side Diff: pdf/control.cc

Issue 519873002: Avoid OOB memcpy in chrome_pdf::CopyImage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename function for clarity. Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | pdf/draw_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/control.h" 5 #include "pdf/control.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "pdf/draw_utils.h" 8 #include "pdf/draw_utils.h"
9 9
10 namespace chrome_pdf { 10 namespace chrome_pdf {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // Some rects in the input list may overlap. To prevent double 46 // Some rects in the input list may overlap. To prevent double
47 // painting (causes problems with semi-transparent controls) we'll 47 // painting (causes problems with semi-transparent controls) we'll
48 // paint control into buffer image data only once and copy requested 48 // paint control into buffer image data only once and copy requested
49 // rectangles. 49 // rectangles.
50 pp::ImageData buffer(owner()->GetInstance(), image_data->format(), 50 pp::ImageData buffer(owner()->GetInstance(), image_data->format(),
51 rect().size(), false); 51 rect().size(), false);
52 if (buffer.is_null()) 52 if (buffer.is_null())
53 return; 53 return;
54 54
55 pp::Rect draw_rc = pp::Rect(image_data->size()).Intersect(rect()); 55 pp::Rect draw_rc = pp::Rect(image_data->size()).Intersect(rect());
56 pp::Rect ctrl_rc = pp::Rect(rect().point() - draw_rc.point(), draw_rc.size()); 56 pp::Rect ctrl_rc = pp::Rect(draw_rc.point() - rect().point(), draw_rc.size());
57 CopyImage(*image_data, draw_rc, &buffer, ctrl_rc, false); 57 CopyImage(*image_data, draw_rc, &buffer, ctrl_rc, false);
58 58
59 // Temporary move control to origin (0,0) and draw it into temp buffer. 59 // Temporary move control to origin (0,0) and draw it into temp buffer.
60 // Move to the original position afterward. Since this is going on temp 60 // Move to the original position afterward. Since this is going on temp
61 // buffer, we don't need to invalidate here. 61 // buffer, we don't need to invalidate here.
62 pp::Rect temp = rect(); 62 pp::Rect temp = rect();
63 MoveTo(pp::Point(0, 0), false); 63 MoveTo(pp::Point(0, 0), false);
64 Paint(&buffer, ctrl_rc); 64 Paint(&buffer, ctrl_rc);
65 MoveTo(temp.point(), false); 65 MoveTo(temp.point(), false);
66 66
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 owner()->Invalidate(id(), old_rc); 108 owner()->Invalidate(id(), old_rc);
109 owner()->Invalidate(id(), rect()); 109 owner()->Invalidate(id(), rect());
110 } 110 }
111 } 111 }
112 112
113 void Control::MoveTo(const pp::Point& origin, bool invalidate) { 113 void Control::MoveTo(const pp::Point& origin, bool invalidate) {
114 MoveBy(origin - rc_.point(), invalidate); 114 MoveBy(origin - rc_.point(), invalidate);
115 } 115 }
116 116
117 } // namespace chrome_pdf 117 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | pdf/draw_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698