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

Unified Diff: pdf/draw_utils.cc

Issue 544863002: Preven OOB memory access in chrome_pdf::AlphaBlend(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/draw_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/draw_utils.cc
diff --git a/pdf/draw_utils.cc b/pdf/draw_utils.cc
index 7f999f060d49f334a291634374f4f6413a662e2a..d38be52aef92da58839ab5c29f64138c7d95d415 100644
--- a/pdf/draw_utils.cc
+++ b/pdf/draw_utils.cc
@@ -57,9 +57,16 @@ inline bool ImageDataContainsRect(const pp::ImageData& image_data,
pp::Rect(image_data.size()).Contains(rect);
}
-bool AlphaBlend(const pp::ImageData& src, const pp::Rect& src_rc,
+void AlphaBlend(const pp::ImageData& src, const pp::Rect& src_rc,
pp::ImageData* dest, const pp::Point& dest_origin,
uint8 alpha_adjustment) {
+ if (src_rc.IsEmpty() || !ImageDataContainsRect(src, src_rc))
+ return;
+
+ pp::Rect dest_rc(dest_origin, src_rc.size());
+ if (dest_rc.IsEmpty() || !ImageDataContainsRect(*dest, dest_rc))
+ return;
+
const uint32_t* src_origin_pixel = src.GetAddr32(src_rc.point());
uint32_t* dest_origin_pixel = dest->GetAddr32(dest_origin);
@@ -86,7 +93,6 @@ bool AlphaBlend(const pp::ImageData& src, const pp::Rect& src_rc,
dest_origin_pixel = reinterpret_cast<uint32_t*>(
reinterpret_cast<char*>(dest_origin_pixel) + dest->stride());
}
- return true;
}
void GradientFill(pp::ImageData* image, const pp::Rect& rc,
« no previous file with comments | « pdf/draw_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698