hrev46695 adds 1 changeset to branch 'master' old head: bb03a92ef61baf91eb9fc8c5d92fdbdfec4ccf45 new head: ab390d3af3a0167584041758de25f383660c5332 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=ab390d3+%5Ebb03a92 ---------------------------------------------------------------------------- ab390d3: Style fixes and allocation checks [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev46695 Commit: ab390d3af3a0167584041758de25f383660c5332 URL: http://cgit.haiku-os.org/haiku/commit/?id=ab390d3 Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Fri Jan 17 14:05:05 2014 UTC ---------------------------------------------------------------------------- 2 files changed, 22 insertions(+), 7 deletions(-) src/kits/network/libnetapi/HttpRequest.cpp | 25 ++++++++++++++++++++----- src/kits/network/libnetapi/SecureSocket.cpp | 4 ++-- ---------------------------------------------------------------------------- diff --git a/src/kits/network/libnetapi/HttpRequest.cpp b/src/kits/network/libnetapi/HttpRequest.cpp index dda7920..d319416 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 566489c..e5f1733 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;