Should check NULL return on CHttpConnection::OpenRequest() and CInternetSession::GetHttpConnection()

drjackool 956 Reputation points
2021-09-01T08:30:14.477+00:00

Hi
Should check NULL return on CHttpConnection::OpenRequest() and CInternetSession::GetHttpConnection()?! because these functions throw an exception on fail and I have to use try-catch block.

try
{
pConnection = pSession->GetHttpConnection(...);
}
catch (CInternetException* e)
{
e->Delete();
        return;
}

if (pConnection) // can remove this if; is it safe?
{
}

thanks

Developer technologies Visual Studio Other
0 comments No comments
{count} votes

Accepted answer
  1. David Lowndes 4,726 Reputation points
    2021-09-01T08:44:59.14+00:00

    They're not documented to return NULL, so the check should be pointless.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.