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

Unified Diff: printing/backend/print_backend_win.cc

Issue 175603002: Less strict CHECK for DeviceCapabilities results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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: printing/backend/print_backend_win.cc
diff --git a/printing/backend/print_backend_win.cc b/printing/backend/print_backend_win.cc
index ec52c99e3dcd54932a7e0c2a862c674ff4166800..f215c6bf9b6ba61e58b869d7b20985f0f23af124 100644
--- a/printing/backend/print_backend_win.cc
+++ b/printing/backend/print_backend_win.cc
@@ -8,6 +8,7 @@
#include <winspool.h>
#include "base/memory/scoped_ptr.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/scoped_bstr.h"
@@ -42,10 +43,15 @@ void GetDeviceCapabilityArray(const wchar_t* printer,
int count = DeviceCapabilities(printer, port, id, NULL, NULL);
if (count <= 0)
return;
- result->resize(count);
- CHECK_EQ(count,
- DeviceCapabilities(printer, port, id,
- reinterpret_cast<LPTSTR>(result->data()), NULL));
+ std::vector<T> tmp;
+ tmp.resize(count * 2);
+ count = DeviceCapabilities(printer, port, id,
+ reinterpret_cast<LPTSTR>(tmp.data()), NULL);
+ if (count <= 0)
+ return;
+ CHECK_LE(count, base::checked_cast<int>(tmp.size()));
+ tmp.resize(count);
+ result->swap(tmp);
}
void LoadPaper(const wchar_t* printer,
« 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