diff options
author | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 18:44:49 +0000 |
---|---|---|
committer | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 18:44:49 +0000 |
commit | 39900b44ac1515cafacbe33d0578e52b9eafb25b (patch) | |
tree | 2d599e91cdbeef8105a01a87f1613826d5b5b816 /chrome/service | |
parent | 803b99a59de96da67e52a33146811585c0850041 (diff) | |
download | chromium_src-39900b44ac1515cafacbe33d0578e52b9eafb25b.zip chromium_src-39900b44ac1515cafacbe33d0578e52b9eafb25b.tar.gz chromium_src-39900b44ac1515cafacbe33d0578e52b9eafb25b.tar.bz2 |
Fixed a crash with some HP printer drivers (when invoking PTGetPrintCapabilities on them).
Detailed story:
Calls to XPS APIs typically require the XPS provider to be opened with
PTOpenProvider. PTOpenProvider calls CoInitializeEx with
COINIT_MULTITHREADED. We have seen certain buggy HP printer driver DLLs
that call CoInitializeEx with COINIT_APARTMENTTHREADED in the context of
PTGetPrintCapabilities. This call fails but the printer driver calls
CoUninitialize anyway. This results in the apartment being torn down too
early and the msxml DLL being unloaded which in turn causes code in
unidrvui.dll to have a dangling pointer to an XML document which causes a
crash. To protect ourselves from such drivers we make sure we always have
an extra CoInitialize (calls to CoInitialize/CoUninitialize are
refcounted).
BUG=None
TEST=Test Cloud Print Proxy on Windows with HP Photosmart 7960 series printers.
Review URL: http://codereview.chromium.org/6037019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70754 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r-- | chrome/service/cloud_print/print_system_win.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/chrome/service/cloud_print/print_system_win.cc b/chrome/service/cloud_print/print_system_win.cc index d77217f..88c38d9 100644 --- a/chrome/service/cloud_print/print_system_win.cc +++ b/chrome/service/cloud_print/print_system_win.cc @@ -76,6 +76,11 @@ HRESULT PrintTicketToDevMode(const std::string& printer_name, const std::string& print_ticket, DevMode* dev_mode) { DCHECK(dev_mode); + printing::ScopedXPSInitializer xps_initializer; + if (!xps_initializer.initialized()) { + // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll) + return E_FAIL; + } ScopedComPtr<IStream> pt_stream; HRESULT hr = StreamFromPrintTicket(print_ticket, pt_stream.Receive()); @@ -383,10 +388,6 @@ class PrintSystemWin : public PrintSystem { return false; } - if (!printing::XPSModule::Init()) { - // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll) - return false; - } DevMode pt_dev_mode; HRESULT hr = PrintTicketToDevMode(printer_name, print_ticket, &pt_dev_mode); @@ -394,6 +395,7 @@ class PrintSystemWin : public PrintSystem { NOTREACHED(); return false; } + HDC dc = CreateDC(L"WINSPOOL", UTF8ToWide(printer_name).c_str(), NULL, pt_dev_mode.dm_); if (!dc) { @@ -618,7 +620,8 @@ bool PrintSystemWin::IsValidPrinter(const std::string& printer_name) { bool PrintSystemWin::ValidatePrintTicket( const std::string& printer_name, const std::string& print_ticket_data) { - if (!printing::XPSModule::Init()) { + printing::ScopedXPSInitializer xps_initializer; + if (!xps_initializer.initialized()) { // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll) return false; } |