From c674fbd6a70f88b57f372bd41cc4f81ab59e0936 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Tue, 25 Aug 2015 08:22:57 +0100 Subject: [PATCH] Bug 1190036 - clipboardData.getFilesAndDirectories() should throw an exception when returning null, r=smaug --- dom/events/DataTransfer.cpp | 10 ++++++++-- dom/events/crashtests/1190036-1.html | 15 +++++++++++++++ dom/events/crashtests/crashtests.list | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 dom/events/crashtests/1190036-1.html diff --git a/dom/events/DataTransfer.cpp b/dom/events/DataTransfer.cpp index 20d9cb97977..48d4478cc74 100644 --- a/dom/events/DataTransfer.cpp +++ b/dom/events/DataTransfer.cpp @@ -850,12 +850,14 @@ DataTransfer::GetFilesAndDirectories(ErrorResult& aRv) { nsCOMPtr parentNode = do_QueryInterface(mParent); if (!parentNode) { + aRv.Throw(NS_ERROR_FAILURE); return nullptr; } nsCOMPtr global = parentNode->OwnerDoc()->GetScopeObject(); MOZ_ASSERT(global); if (!global) { + aRv.Throw(NS_ERROR_FAILURE); return nullptr; } @@ -865,9 +867,13 @@ DataTransfer::GetFilesAndDirectories(ErrorResult& aRv) } if (!mFiles) { - ErrorResult dummy; - GetFiles(dummy); + GetFiles(aRv); + if (NS_WARN_IF(aRv.Failed())) { + return nullptr; + } + if (!mFiles) { + aRv.Throw(NS_ERROR_FAILURE); return nullptr; } } diff --git a/dom/events/crashtests/1190036-1.html b/dom/events/crashtests/1190036-1.html new file mode 100644 index 00000000000..00a6a25db6b --- /dev/null +++ b/dom/events/crashtests/1190036-1.html @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/dom/events/crashtests/crashtests.list b/dom/events/crashtests/crashtests.list index 686b5b89231..1f22621e430 100644 --- a/dom/events/crashtests/crashtests.list +++ b/dom/events/crashtests/crashtests.list @@ -9,6 +9,7 @@ load 1033343.html load 1035654-1.html load 1035654-2.html load 1143972-1.html +load 1190036-1.html needs-focus load 1072137-1.html load eventctor-nulldictionary.html load eventctor-nullstorage.html