From ff12c3d22cae6f134503d0ac5923c2cf3adf2668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 8 Apr 2022 01:00:32 +0000 Subject: [PATCH] Bug 1763679 - Null-check in PrintTargetPDF, rather than relying on the caller to do so. r=hiro Differential Revision: https://phabricator.services.mozilla.com/D143245 --- gfx/thebes/PrintTargetPDF.cpp | 4 ++++ widget/gtk/nsDeviceContextSpecG.cpp | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/thebes/PrintTargetPDF.cpp b/gfx/thebes/PrintTargetPDF.cpp index e89ec1b1ec4b..8c2910f9e0c5 100644 --- a/gfx/thebes/PrintTargetPDF.cpp +++ b/gfx/thebes/PrintTargetPDF.cpp @@ -49,6 +49,10 @@ PrintTargetPDF::~PrintTargetPDF() { /* static */ already_AddRefed PrintTargetPDF::CreateOrNull( nsIOutputStream* aStream, const IntSize& aSizeInPoints) { + if (NS_WARN_IF(!aStream)) { + return nullptr; + } + cairo_surface_t* surface = cairo_pdf_surface_create_for_stream( write_func, (void*)aStream, aSizeInPoints.width, aSizeInPoints.height); if (cairo_surface_status(surface)) { diff --git a/widget/gtk/nsDeviceContextSpecG.cpp b/widget/gtk/nsDeviceContextSpecG.cpp index 5f3132565fa9..daf38ac90ca4 100644 --- a/widget/gtk/nsDeviceContextSpecG.cpp +++ b/widget/gtk/nsDeviceContextSpecG.cpp @@ -110,10 +110,6 @@ already_AddRefed nsDeviceContextSpecGTK::MakePrintTarget() { return stream; }(); - if (!stream) { - return nullptr; - } - return PrintTargetPDF::CreateOrNull(stream, IntSize::Ceil(width, height)); }