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: printing/page_range.cc

Issue 25651002: Fixed memory overflow caused by invalid input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | printing/page_range_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/page_range.cc
diff --git a/printing/page_range.cc b/printing/page_range.cc
index 7a8cb84c84c70e58fdd8a23bef7fd31bad96adeb..ea2e30a38cbc262657e42209d10c1f9ab529c143 100644
--- a/printing/page_range.cc
+++ b/printing/page_range.cc
@@ -5,18 +5,24 @@
#include "printing/page_range.h"
#include <set>
-#include <vector>
+
+namespace {
+const std::size_t kMaxNumberOfPages = 100000;
+}
namespace printing {
/* static */
std::vector<int> PageRange::GetPages(const PageRanges& ranges) {
+ // TODO(vitalybuka): crbug.com/95548 Remove this method as part fix.
std::set<int> pages;
for (unsigned i = 0; i < ranges.size(); ++i) {
const PageRange& range = ranges[i];
// Ranges are inclusive.
for (int i = range.from; i <= range.to; ++i) {
pages.insert(i);
+ if (pages.size() >= kMaxNumberOfPages)
+ return std::vector<int>(pages.begin(), pages.end());
}
}
return std::vector<int>(pages.begin(), pages.end());
« no previous file with comments | « no previous file | printing/page_range_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698