diff options
Diffstat (limited to 'src/network/access/qhttpthreaddelegate.cpp')
-rw-r--r-- | src/network/access/qhttpthreaddelegate.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index c5c35d522a..b0ae0dcf44 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -567,11 +567,6 @@ void QHttpThreadDelegate::synchronousFinishedWithErrorSlot(QNetworkReply::Networ httpReply = nullptr; } -static void downloadBufferDeleter(char *ptr) -{ - delete[] ptr; -} - void QHttpThreadDelegate::headerChangedSlot() { if (!httpReply) @@ -589,14 +584,11 @@ void QHttpThreadDelegate::headerChangedSlot() // Is using a zerocopy buffer allowed by user and possible with this reply? if (httpReply->supportsUserProvidedDownloadBuffer() && (downloadBufferMaximumSize > 0) && (httpReply->contentLength() <= downloadBufferMaximumSize)) { - QT_TRY { - char *buf = new char[httpReply->contentLength()]; // throws if allocation fails - if (buf) { - downloadBuffer = QSharedPointer<char>(buf, downloadBufferDeleter); - httpReply->setUserProvidedDownloadBuffer(buf); - } - } QT_CATCH(const std::bad_alloc &) { - // in out of memory situations, don't use downloadbuffer. + char *buf = new (std::nothrow) char[httpReply->contentLength()]; + // in out of memory situations, don't use downloadBuffer. + if (buf) { + downloadBuffer = QSharedPointer<char>(buf, [](auto p) { delete[] p; }); + httpReply->setUserProvidedDownloadBuffer(buf); } } |