summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfont.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-09-16 16:55:17 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-09-24 14:38:40 +0200
commit06cc5d307177ebacf8e6926b9690c12703004a1a (patch)
tree6143b0eaa7318a414da86d97c87fe5bb507b85ae /src/gui/text/qfont.cpp
parent74179a209a8ccdc771b0218f430d5a0519bc619a (diff)
Ensure that QFont::fromString() doesn't parse empty font specifications
Fixes: QTBUG-78236 Change-Id: Iba060e7a24080cdc8f317ecb6dc616b2cd918acb Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/gui/text/qfont.cpp')
-rw-r--r--src/gui/text/qfont.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 1dbb03948d..84c5be60b1 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -2098,10 +2098,11 @@ uint qHash(const QFont &font, uint seed) Q_DECL_NOTHROW
*/
bool QFont::fromString(const QString &descrip)
{
- const auto l = descrip.splitRef(QLatin1Char(','));
-
- int count = l.count();
- if (!count || (count > 2 && count < 9) || count > 11) {
+ const QStringRef sr = QStringRef(&descrip).trimmed();
+ const auto l = sr.split(QLatin1Char(','));
+ const int count = l.count();
+ if (!count || (count > 2 && count < 9) || count > 11 ||
+ l.first().isEmpty()) {
qWarning("QFont::fromString: Invalid description '%s'",
descrip.isEmpty() ? "(empty)" : descrip.toLatin1().data());
return false;