From 9fa181446c446d315c592fa46acf7877d281fc65 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 11 Mar 2021 16:04:50 +0100 Subject: Minor robustness improvement of text code Fix a potential issue reported by static analysis Change-Id: I41b8eaa3c0840eec054e880c4f3298ee32685b46 Reviewed-by: Konstantin Ritt --- src/gui/text/qtextdocumentwriter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gui/text') diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp index 31dfb9436f..db2129d809 100644 --- a/src/gui/text/qtextdocumentwriter.cpp +++ b/src/gui/text/qtextdocumentwriter.cpp @@ -240,9 +240,11 @@ QString QTextDocumentWriter::fileName () const */ bool QTextDocumentWriter::write(const QTextDocument *document) { - QByteArray suffix; + if (!d->device) + return false; - if (d->device && d->format.isEmpty()) { + QByteArray suffix; + if (d->format.isEmpty()) { // if there's no format, see if device is a file, and if so, find // the file suffix if (QFile *file = qobject_cast(d->device)) -- cgit v1.2.3