diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 261a1eccd67..b0ae0dcf446 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -584,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(buf, [](auto p) { delete[] p; }); - 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(buf, [](auto p) { delete[] p; }); + httpReply->setUserProvidedDownloadBuffer(buf); } }