From b72d41cf30f82c74c10c31808907cc990c86efe6 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 3 Nov 2009 08:23:18 +1000 Subject: Protect the OpenVG engine from null QPixmapData objects Reviewed-by: Sarah Smith --- src/openvg/qpaintengine_vg.cpp | 10 ++++++++++ src/openvg/qpixmapdata_vg.cpp | 2 ++ src/openvg/qpixmapfilter_vg.cpp | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 8a485a0..047d9d8 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1178,6 +1178,8 @@ VGPaintType QVGPaintEnginePrivate::setBrush case Qt::TexturePattern: { // The brush is a texture specified by a QPixmap/QImage. QPixmapData *pd = brush.texture().pixmapData(); + if (!pd) + break; // null QPixmap VGImage vgImg; bool deref = false; if (pd->pixelType() == QPixmapData::BitmapType) { @@ -2893,6 +2895,8 @@ void qt_vg_drawVGImageStencil void QVGPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { QPixmapData *pd = pm.pixmapData(); + if (!pd) + return; // null QPixmap if (pd->classId() == QPixmapData::OpenVGClass) { Q_D(QVGPaintEngine); QVGPixmapData *vgpd = static_cast(pd); @@ -2910,6 +2914,8 @@ void QVGPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF void QVGPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pm) { QPixmapData *pd = pm.pixmapData(); + if (!pd) + return; // null QPixmap if (pd->classId() == QPixmapData::OpenVGClass) { Q_D(QVGPaintEngine); QVGPixmapData *vgpd = static_cast(pd); @@ -2985,6 +2991,8 @@ void QVGPaintEngine::drawPixmaps // If the pixmap is not VG, or the transformation is projective, // then fall back to the default implementation. QPixmapData *pd = pixmap.pixmapData(); + if (!pd) + return; // null QPixmap if (pd->classId() != QPixmapData::OpenVGClass || !d->simpleTransform) { QPaintEngineEx::drawPixmaps(drawingData, dataCount, pixmap, hints); return; @@ -3581,6 +3589,8 @@ void QVGCompositionHelper::drawCursorPixmap // Fetch the VGImage from the pixmap if possible. QPixmapData *pd = pixmap.pixmapData(); + if (!pd) + return; // null QPixmap if (pd->classId() == QPixmapData::OpenVGClass) { QVGPixmapData *vgpd = static_cast(pd); if (vgpd->isValid()) diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index f86e116..3254aa3 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -369,6 +369,8 @@ QImage::Format QVGPixmapData::sourceFormat() const Q_OPENVG_EXPORT VGImage qPixmapToVGImage(const QPixmap& pixmap) { QPixmapData *pd = pixmap.pixmapData(); + if (!pd) + return VG_INVALID_HANDLE; // null QPixmap if (pd->classId() == QPixmapData::OpenVGClass) { QVGPixmapData *vgpd = static_cast(pd); if (vgpd->isValid()) diff --git a/src/openvg/qpixmapfilter_vg.cpp b/src/openvg/qpixmapfilter_vg.cpp index 8e104db..e17c728 100644 --- a/src/openvg/qpixmapfilter_vg.cpp +++ b/src/openvg/qpixmapfilter_vg.cpp @@ -65,6 +65,9 @@ void QVGPixmapConvolutionFilter::draw (QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { + if (src.isNull()) + return; + if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) { // The pixmap data is not an instance of QVGPixmapData, so fall // back to the default convolution filter implementation. @@ -135,6 +138,9 @@ QVGPixmapColorizeFilter::~QVGPixmapColorizeFilter() void QVGPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { + if (src.isNull()) + return; + if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) { // The pixmap data is not an instance of QVGPixmapData, so fall // back to the default colorize filter implementation. @@ -225,6 +231,9 @@ QVGPixmapDropShadowFilter::~QVGPixmapDropShadowFilter() void QVGPixmapDropShadowFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { + if (src.isNull()) + return; + if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) { // The pixmap data is not an instance of QVGPixmapData, so fall // back to the default drop shadow filter implementation. @@ -290,6 +299,9 @@ QVGPixmapBlurFilter::~QVGPixmapBlurFilter() void QVGPixmapBlurFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { + if (src.isNull()) + return; + if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) { // The pixmap data is not an instance of QVGPixmapData, so fall // back to the default blur filter implementation. -- cgit v0.12