Bug 1779521 - Check for null principal when drawing images to a canvas element. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D151819
This commit is contained in:
Andrew Osmond 2022-07-14 18:04:30 +00:00
parent 5e791d5c28
commit e304a056df

View File

@ -244,7 +244,11 @@ void DoDrawImageSecurityCheck(dom::HTMLCanvasElement* aCanvasElement,
// No need to do a security check if the image used CORS for the load
if (CORSUsed) return;
MOZ_ASSERT(aPrincipal, "Must have a principal here");
if (NS_WARN_IF(!aPrincipal)) {
MOZ_ASSERT_UNREACHABLE("Must have a principal here");
aCanvasElement->SetWriteOnly();
return;
}
if (aCanvasElement->NodePrincipal()->Subsumes(aPrincipal)) {
// This canvas has access to that image anyway