From 9d4e6d560a5c3c229bdcaa6b15f2028cc9805346 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 28 Feb 2022 17:15:37 +0100 Subject: [PATCH] QMimeMagicRule: Fix missing check and return for "Invalid" type In the QMimeMagicRule constructor. Change-Id: Icdd1c4bc0e8d7cc39c8f63b416deec84b2607c96 Reviewed-by: David Faure --- src/corelib/mimetypes/qmimemagicrule.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index 2c8c2e7199..bb30c11ff5 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -231,8 +231,11 @@ QMimeMagicRule::QMimeMagicRule(const QString &type, m_mask(mask), m_matchFunction(nullptr) { - if (Q_UNLIKELY(m_type == Invalid)) - *errorString = QLatin1String("Type ") + type + QLatin1String(" is not supported"); + if (Q_UNLIKELY(m_type == Invalid)) { + if (errorString) + *errorString = QLatin1String("Type ") + type + QLatin1String(" is not supported"); + return; + } // Parse for offset as "1" or "1:10" const int colonIndex = offsets.indexOf(QLatin1Char(':'));