[haiku-commits] Re: haiku: hrev46686 - src/kits/network/libnetapi

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 16 Jan 2014 11:56:20 +0100

On 16.01.2014 11:30, pulkomandy@xxxxxxxxxxxxx wrote:
@@ -114,15 +154,17 @@ BSecureSocket::Private::VerifyCallback(int ok, 
X509_STORE_CTX* ctx)

  BSecureSocket::BSecureSocket()
        :
-       fPrivate(NULL)
+       fPrivate(new BSecureSocket::Private())
  {
+       fInitStatus = fPrivate != NULL ? fPrivate->InitCheck() : B_NO_MEMORY;
  }


  BSecureSocket::BSecureSocket(const BNetworkAddress& peer, bigtime_t timeout)
        :
-       fPrivate(NULL)
+       fPrivate(new BSecureSocket::Private())
  {
+       fInitStatus = fPrivate != NULL ? fPrivate->InitCheck() : B_NO_MEMORY;
        Connect(peer, timeout);
  }

fPrivate will not be NULL in case of allocation failure, instead "new" will have thrown std::bad_alloc in the constructor. So use new(std::nothrow) when you actually want the returning NULL behaviour.

Best regards,
-Stephan


Other related posts: