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

Side by Side Diff: printing/backend/win_helper.cc

Issue 172813003: Added NULL pointer check for DEVMODE. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "printing/backend/win_helper.h" 5 #include "printing/backend/win_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/file_version_info.h" 9 #include "base/file_version_info.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 printing::XPSModule::CloseProvider(provider); 425 printing::XPSModule::CloseProvider(provider);
426 } 426 }
427 return scoped_dev_mode.Pass(); 427 return scoped_dev_mode.Pass();
428 } 428 }
429 429
430 scoped_ptr<DEVMODE[]> CreateDevModeWithColor(HANDLE printer, 430 scoped_ptr<DEVMODE[]> CreateDevModeWithColor(HANDLE printer,
431 const base::string16& printer_name, 431 const base::string16& printer_name,
432 bool color) { 432 bool color) {
433 scoped_ptr<DEVMODE[]> default = CreateDevMode(printer, NULL); 433 scoped_ptr<DEVMODE[]> default = CreateDevMode(printer, NULL);
434 if (default && (default.get()->dmFields & DM_COLOR) && 434 if (!default)
435 return default.Pass();
436
437 if ((default.get()->dmFields & DM_COLOR) &&
435 ((default.get()->dmColor == DMCOLOR_COLOR) == color)) { 438 ((default.get()->dmColor == DMCOLOR_COLOR) == color)) {
436 return default.Pass(); 439 return default.Pass();
437 } 440 }
438 441
439 default.get()->dmFields |= DM_COLOR; 442 default.get()->dmFields |= DM_COLOR;
440 default.get()->dmColor = color ? DMCOLOR_COLOR : DMCOLOR_MONOCHROME; 443 default.get()->dmColor = color ? DMCOLOR_COLOR : DMCOLOR_MONOCHROME;
441 444
442 DriverInfo6 info_6; 445 DriverInfo6 info_6;
443 if (!info_6.Init(printer)) 446 if (!info_6.Init(printer))
444 return default.Pass(); 447 return default.Pass();
(...skipping 28 matching lines...) Expand all
473 scoped_ptr<DEVMODE[]> out( 476 scoped_ptr<DEVMODE[]> out(
474 reinterpret_cast<DEVMODE*>(new uint8[buffer_size])); 477 reinterpret_cast<DEVMODE*>(new uint8[buffer_size]));
475 flags |= DM_OUT_BUFFER; 478 flags |= DM_OUT_BUFFER;
476 if (DocumentProperties(NULL, printer, L"", out.get(), in, flags) != IDOK) 479 if (DocumentProperties(NULL, printer, L"", out.get(), in, flags) != IDOK)
477 return scoped_ptr<DEVMODE[]>(); 480 return scoped_ptr<DEVMODE[]>();
478 DCHECK_EQ(buffer_size, out.get()->dmSize + out.get()->dmDriverExtra); 481 DCHECK_EQ(buffer_size, out.get()->dmSize + out.get()->dmDriverExtra);
479 return out.Pass(); 482 return out.Pass();
480 } 483 }
481 484
482 } // namespace printing 485 } // namespace printing
OLDNEW
« 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