From 4f7cb2c84535543e68e2728ab784c0812edb4b8e Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Tue, 18 Jun 2024 09:18:08 +0000 Subject: [PATCH] Bug 1902305 - Check if clipboard type is supported in `nsBaseClipboard::HasDataMatchingFlavors`; r=tschuster Differential Revision: https://phabricator.services.mozilla.com/D213766 --- widget/nsBaseClipboard.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/widget/nsBaseClipboard.cpp b/widget/nsBaseClipboard.cpp index 1eb2e8e9e0a1..1ccba2e6a5fd 100644 --- a/widget/nsBaseClipboard.cpp +++ b/widget/nsBaseClipboard.cpp @@ -777,6 +777,13 @@ nsBaseClipboard::HasDataMatchingFlavors(const nsTArray& aFlavorList, int32_t aWhichClipboard, bool* aOutResult) { MOZ_CLIPBOARD_LOG("%s: clipboard=%d", __FUNCTION__, aWhichClipboard); + + if (!nsIClipboard::IsClipboardTypeSupported(aWhichClipboard)) { + MOZ_CLIPBOARD_LOG("%s: clipboard %d is not supported.", __FUNCTION__, + aWhichClipboard); + return NS_ERROR_FAILURE; + } + if (MOZ_CLIPBOARD_LOG_ENABLED()) { MOZ_CLIPBOARD_LOG(" Asking for content clipboard=%i:\n", aWhichClipboard);