diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 61dc9da1616d..b0f4de85b0f7 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -1046,6 +1046,12 @@ DrawTargetCairo::ClearRect(const Rect& aRect) { AutoPrepareForDrawing prep(this, mContext); + if (!mContext || aRect.Width() <= 0 || aRect.Height() <= 0 || + !IsFinite(aRect.X()) || !IsFinite(aRect.Width()) || + !IsFinite(aRect.Y()) || !IsFinite(aRect.Height())) { + gfxCriticalError() << "ClearRect with invalid argument " << gfx::hexa(mContext) << " with " << aRect.Width() << "x" << aRect.Height() << " [" << aRect.X() << ", " << aRect.Y() << "]"; + } + cairo_set_antialias(mContext, CAIRO_ANTIALIAS_NONE); cairo_new_path(mContext); cairo_set_operator(mContext, CAIRO_OPERATOR_CLEAR);