diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp index dd048abcbf3d3..2fc97d4c64974 100644 --- a/dom/ipc/BrowserParent.cpp +++ b/dom/ipc/BrowserParent.cpp @@ -3838,10 +3838,14 @@ mozilla::ipc::IPCResult BrowserParent::RecvInvokeDragSession( cookieJarSettings, aSourceWindowContext.GetMaybeDiscarded(), aSourceTopWindowContext.GetMaybeDiscarded()); - if (aVisualDnDData && aVisualDnDData->Size() >= aDragRect.height * aStride) { - dragStartData->SetVisualization(gfx::CreateDataSourceSurfaceFromData( - gfx::IntSize(aDragRect.width, aDragRect.height), aFormat, - aVisualDnDData->Data(), aStride)); + if (aVisualDnDData) { + const auto checkedSize = CheckedInt(aDragRect.height) * aStride; + if (checkedSize.isValid() && + aVisualDnDData->Size() >= checkedSize.value()) { + dragStartData->SetVisualization(gfx::CreateDataSourceSurfaceFromData( + gfx::IntSize(aDragRect.width, aDragRect.height), aFormat, + aVisualDnDData->Data(), aStride)); + } } nsCOMPtr dragService =