Index: printing/backend/win_helper.h |
=================================================================== |
--- printing/backend/win_helper.h (revision 237598) |
+++ printing/backend/win_helper.h (working copy) |
@@ -46,10 +46,9 @@ |
base::win::VerifierTraits> { |
public: |
bool OpenPrinter(const wchar_t* printer) { |
- HANDLE temp_handle; |
// ::OpenPrinter may return error but assign some value into handle. |
- if (::OpenPrinter(const_cast<LPTSTR>(printer), &temp_handle, NULL)) { |
- Set(temp_handle); |
+ if (!::OpenPrinter(const_cast<LPTSTR>(printer), Receive(), NULL)) { |
+ Take(); |
} |
return IsValid(); |
} |
@@ -57,6 +56,10 @@ |
private: |
typedef base::win::GenericScopedHandle<PrinterHandleTraits, |
base::win::VerifierTraits> Base; |
+ // Hide Receive to avoid assigning handle when ::OpenPrinter returned error. |
+ Base::Receiver Receive() { |
+ return Base::Receive(); |
+ } |
}; |
class PrinterChangeHandleTraits { |