From 06cc5d307177ebacf8e6926b9690c12703004a1a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 16 Sep 2019 16:55:17 +0200 Subject: Ensure that QFont::fromString() doesn't parse empty font specifications Fixes: QTBUG-78236 Change-Id: Iba060e7a24080cdc8f317ecb6dc616b2cd918acb Reviewed-by: Christian Ehrlicher Reviewed-by: Konstantin Shegunov Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfont.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gui/text/qfont.cpp') 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; -- cgit v1.2.3