Style fixes and allocation checks

This commit is contained in:
Adrien Destugues 2014-01-17 15:05:05 +01:00
parent bb03a92ef6
commit ab390d3af3
2 changed files with 22 additions and 7 deletions

View File

@ -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

View File

@ -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;