diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-02 10:40:59 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-17 18:13:13 +0200 |
commit | 3a53fd9f23ab19ad83093750778f85ab318b9b7a (patch) | |
tree | cfed5a1028dd6e45089045e901d547c4f5bad30c /src/tools/moc/moc.cpp | |
parent | 4e27961db9868cd9d7a8d589dbf0463878dc47e1 (diff) |
Make moc ready for when null byte-arrays have null constData()
Various places in moc relied on the magic behavior of QByteArray, that
provided a non-null pointer to a null byte when the byte array was
null, resulting in crashes when QT5_NULL_STRINGS is turned off. Fixed
them to cope with this (and optimised out some pointless effort, when
empty QByteArrays are involved, in the process).
Change-Id: I617a878eb2e9ac8be244080efa1f0de4ac9a68a2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r-- | src/tools/moc/moc.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 228a21e3c2..15c35234c9 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com> +** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2019 Olivier Goffart <ogoffart@woboq.com> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the tools applications of the Qt Toolkit. @@ -46,8 +46,7 @@ QT_BEGIN_NAMESPACE // only moc needs this function static QByteArray normalizeType(const QByteArray &ba) { - QByteArray result = normalizeTypeInternal(ba.constBegin(), ba.constEnd()); - return result; + return ba.size() ? normalizeTypeInternal(ba.constBegin(), ba.constEnd()) : ba; } bool Moc::parseClassHead(ClassDef *def) |