diff --git a/src/kits/network/libnetapi/HttpRequest.cpp b/src/kits/network/libnetapi/HttpRequest.cpp index dda79205a4..d3194161c1 100644 --- a/src/kits/network/libnetapi/HttpRequest.cpp +++ b/src/kits/network/libnetapi/HttpRequest.cpp @@ -241,7 +241,7 @@ BHttpRequest::Result() const status_t BHttpRequest::Stop() { - if (fSocket) { + if (fSocket != NULL) { fSocket->Disconnect(); // Unlock any pending connect, read or write operation. } @@ -342,7 +342,8 @@ BHttpRequest::_ProtocolLoop() if (authentication->Method() == B_HTTP_AUTHENTICATION_NONE) { // There is no authentication context for this // url yet, so let's create one. - authentication = new(std::nothrow) BHttpAuthentication(); + authentication + = new(std::nothrow) BHttpAuthentication(); if (authentication == NULL) status = B_NO_MEMORY; else { @@ -437,7 +438,8 @@ BHttpRequest::_MakeRequest() if (fListener != NULL) fListener->ConnectionOpened(this); - _EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT, "Connection opened, sending request."); + _EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT, + "Connection opened, sending request."); _SendRequest(); _SendHeaders(); @@ -610,8 +612,15 @@ BHttpRequest::_MakeRequest() if (inputTempSize < chunkSize + 2) { delete[] inputTempBuffer; inputTempSize = chunkSize + 2; - inputTempBuffer = new(std::nothrow) char[inputTempSize]; + inputTempBuffer + = new(std::nothrow) char[inputTempSize]; } + + if (inputTempBuffer == NULL) { + readError = B_NO_MEMORY; + break; + } + fInputBuffer.RemoveData(inputTempBuffer, chunkSize + 2); chunkSize = -1; @@ -658,6 +667,11 @@ BHttpRequest::_MakeRequest() delete[] inputTempBuffer; inputTempBuffer = new(std::nothrow) char[bytesRead]; } + + if (inputTempBuffer == NULL) { + readError = B_NO_MEMORY; + break; + } fInputBuffer.RemoveData(inputTempBuffer, bytesRead); } } @@ -851,7 +865,8 @@ BHttpRequest::_SendHeaders() fOutputHeaders.AddHeader("Content-Length", fOptPostFields->ContentLength()); } else if (fOptInputData != NULL - && (fRequestMethod == B_HTTP_POST || fRequestMethod == B_HTTP_PUT)) { + && (fRequestMethod == B_HTTP_POST + || fRequestMethod == B_HTTP_PUT)) { if (fOptInputDataSize >= 0) fOutputHeaders.AddHeader("Content-Length", fOptInputDataSize); else diff --git a/src/kits/network/libnetapi/SecureSocket.cpp b/src/kits/network/libnetapi/SecureSocket.cpp index 566489ce89..e5f173374a 100644 --- a/src/kits/network/libnetapi/SecureSocket.cpp +++ b/src/kits/network/libnetapi/SecureSocket.cpp @@ -147,8 +147,8 @@ BSecureSocket::Private::VerifyCallback(int ok, X509_STORE_CTX* ctx) // we got from the server, but something higher up in the certificate // chain) X509* x509 = X509_STORE_CTX_get_current_cert(ctx); - BCertificate::Private* certificate = - new(std::nothrow) BCertificate::Private(x509); + BCertificate::Private* certificate + = new(std::nothrow) BCertificate::Private(x509); if (certificate == NULL) return 0;