From fdafce4d3a4670e315c161a9ec79ae6203742d1d Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Wed, 8 Nov 2017 18:45:40 +0300 Subject: Handle std::bad_alloc exception in resolveBlobUrl Original commit: https://github.com/annulen/webkit/commit/3e4b4a4eb1e8ac6d0feb4efa8341212519547296 Change-Id: I335512455c25a8555370eb4ed484d2fdfbf383d4 Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/platform/network/qt/ResourceRequestQt.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp index 2719f1db6..66756b95d 100644 --- a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp @@ -100,13 +100,23 @@ static QUrl resolveBlobUrl(const KURL& url) dataUri.append(QLatin1String(base64.data(), base64.size())); return QUrl(dataUri); } + +QUrl convertBlobToDataUrl(const QUrl& url) +{ + QT_TRY { + return resolveBlobUrl(url); + } QT_CATCH(const std::bad_alloc &) { + qWarning("Failed to convert blob data to base64: not enough memory"); + } + return QUrl(); +} #endif static QUrl toQUrl(const KURL& url) { #if ENABLE(BLOB) if (url.protocolIs("blob")) - return resolveBlobUrl(url); + return convertBlobToDataUrl(url); #endif return url; } -- cgit v1.2.1