Correct improper usage of THROW_IF_NULL_ALLOC (#4128)

Closes #4099
This commit is contained in:
Chester Liu 2020-01-08 05:27:18 +08:00 committed by Dustin L. Howett (MSFT)
parent 5119ed1645
commit 718d334ba5
10 changed files with 12 additions and 12 deletions

View file

@ -34,7 +34,7 @@ PtySignalInputThread::PtySignalInputThread(_In_ wil::unique_hfile hPipe) :
_consoleConnected{ false } _consoleConnected{ false }
{ {
THROW_HR_IF(E_HANDLE, _hFile.get() == INVALID_HANDLE_VALUE); THROW_HR_IF(E_HANDLE, _hFile.get() == INVALID_HANDLE_VALUE);
THROW_IF_NULL_ALLOC(_pConApi.get()); THROW_HR_IF_NULL(E_INVALIDARG, _pConApi.get());
} }
PtySignalInputThread::~PtySignalInputThread() PtySignalInputThread::~PtySignalInputThread()

View file

@ -103,10 +103,10 @@ SCREEN_INFORMATION::~SCREEN_INFORMATION()
try try
{ {
IWindowMetrics* pMetrics = ServiceLocator::LocateWindowMetrics(); IWindowMetrics* pMetrics = ServiceLocator::LocateWindowMetrics();
THROW_IF_NULL_ALLOC(pMetrics); THROW_HR_IF_NULL(E_FAIL, pMetrics);
IAccessibilityNotifier* pNotifier = ServiceLocator::LocateAccessibilityNotifier(); IAccessibilityNotifier* pNotifier = ServiceLocator::LocateAccessibilityNotifier();
THROW_IF_NULL_ALLOC(pNotifier); THROW_HR_IF_NULL(E_FAIL, pNotifier);
SCREEN_INFORMATION* const pScreen = new SCREEN_INFORMATION(pMetrics, pNotifier, popupAttributes, fontInfo); SCREEN_INFORMATION* const pScreen = new SCREEN_INFORMATION(pMetrics, pNotifier, popupAttributes, fontInfo);

View file

@ -133,7 +133,7 @@ void Clipboard::StringPaste(_In_reads_(cchData) const wchar_t* const pData,
std::deque<std::unique_ptr<IInputEvent>> Clipboard::TextToKeyEvents(_In_reads_(cchData) const wchar_t* const pData, std::deque<std::unique_ptr<IInputEvent>> Clipboard::TextToKeyEvents(_In_reads_(cchData) const wchar_t* const pData,
const size_t cchData) const size_t cchData)
{ {
THROW_IF_NULL_ALLOC(pData); THROW_HR_IF_NULL(E_INVALIDARG, pData);
std::deque<std::unique_ptr<IInputEvent>> keyEvents; std::deque<std::unique_ptr<IInputEvent>> keyEvents;

View file

@ -931,6 +931,6 @@ std::vector<SMALL_RECT> Renderer::_GetSelectionRects() const
// engine to our collection. // engine to our collection.
void Renderer::AddRenderEngine(_In_ IRenderEngine* const pEngine) void Renderer::AddRenderEngine(_In_ IRenderEngine* const pEngine)
{ {
THROW_IF_NULL_ALLOC(pEngine); THROW_HR_IF_NULL(E_INVALIDARG, pEngine);
_rgpEngines.push_back(pEngine); _rgpEngines.push_back(pEngine);
} }

View file

@ -1735,7 +1735,7 @@ float DxEngine::GetScaling() const noexcept
} }
} }
THROW_IF_NULL_ALLOC(face); THROW_HR_IF_NULL(E_FAIL, face);
return face; return face;
} }

View file

@ -17,7 +17,7 @@ using namespace Microsoft::Console::VirtualTerminal;
InteractDispatch::InteractDispatch(std::unique_ptr<ConGetSet> pConApi) : InteractDispatch::InteractDispatch(std::unique_ptr<ConGetSet> pConApi) :
_pConApi(std::move(pConApi)) _pConApi(std::move(pConApi))
{ {
THROW_IF_NULL_ALLOC(_pConApi.get()); THROW_HR_IF_NULL(E_INVALIDARG, _pConApi.get());
} }
// Method Description: // Method Description:

View file

@ -36,8 +36,8 @@ AdaptDispatch::AdaptDispatch(std::unique_ptr<ConGetSet> pConApi,
_changedMetaAttrs(false), _changedMetaAttrs(false),
_termOutput() _termOutput()
{ {
THROW_IF_NULL_ALLOC(_pConApi.get()); THROW_HR_IF_NULL(E_INVALIDARG, _pConApi.get());
THROW_IF_NULL_ALLOC(_pDefaults.get()); THROW_HR_IF_NULL(E_INVALIDARG, _pDefaults.get());
_scrollMargins = { 0 }; // initially, there are no scroll margins. _scrollMargins = { 0 }; // initially, there are no scroll margins.
} }

View file

@ -170,7 +170,7 @@ InputStateMachineEngine::InputStateMachineEngine(std::unique_ptr<IInteractDispat
_pDispatch(std::move(pDispatch)), _pDispatch(std::move(pDispatch)),
_lookingForDSR(lookingForDSR) _lookingForDSR(lookingForDSR)
{ {
THROW_IF_NULL_ALLOC(_pDispatch.get()); THROW_HR_IF_NULL(E_INVALIDARG, _pDispatch.get());
} }
// Method Description: // Method Description:

View file

@ -17,7 +17,7 @@ OutputStateMachineEngine::OutputStateMachineEngine(std::unique_ptr<ITermDispatch
_pTtyConnection(nullptr), _pTtyConnection(nullptr),
_lastPrintedChar(AsciiChars::NUL) _lastPrintedChar(AsciiChars::NUL)
{ {
THROW_IF_NULL_ALLOC(_dispatch.get()); THROW_HR_IF_NULL(E_INVALIDARG, _dispatch.get());
} }
const ITermDispatch& OutputStateMachineEngine::Dispatch() const noexcept const ITermDispatch& OutputStateMachineEngine::Dispatch() const noexcept

View file

@ -24,7 +24,7 @@ VtConsole::VtConsole(PipeReadCallback const pfnReadCallback,
_fUseConPty(fUseConpty), _fUseConPty(fUseConpty),
_lastDimensions(initialSize) _lastDimensions(initialSize)
{ {
THROW_IF_NULL_ALLOC(pfnReadCallback); THROW_HR_IF_NULL(E_INVALIDARG, pfnReadCallback);
} }
void VtConsole::spawn() void VtConsole::spawn()