From fda299f55dd5aeb2d075f6f5c842f75c9f559f9c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 21 Mar 2011 10:30:51 +0100 Subject: Don't crash calling QTextDocument::blockBoundingRect on invalid block If the block is invalid, QTextBlock::layout() will return 0 and we would dereference a null pointer. Task-number: QTBUG-18192 Reviewed-by: Jiang Jiang --- src/gui/text/qtextdocumentlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index d721c91..65fe0f8 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -3133,7 +3133,7 @@ QRectF QTextDocumentLayoutPrivate::frameBoundingRectInternal(QTextFrame *frame) QRectF QTextDocumentLayout::blockBoundingRect(const QTextBlock &block) const { Q_D(const QTextDocumentLayout); - if (d->docPrivate->pageSize.isNull()) + if (d->docPrivate->pageSize.isNull() || !block.isValid()) return QRectF(); d->ensureLayoutedByPosition(block.position() + block.length()); QTextFrame *frame = d->document->frameAt(block.position()); -- cgit v0.12