summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qlibrary.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-09-10 18:00:46 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-10-04 14:01:37 -0700
commit16e7366b5ce61418a69ba13a74996514b69dac37 (patch)
treed241f95c655205693ccf1bbf04701f4f87541e70 /src/corelib/plugin/qlibrary.cpp
parent788a7bfdb1981108efbf55bc42a468ca0e8b102e (diff)
QPlugin: use one global metadata magic string
And use QByteArrayView where applicable. Change-Id: I2de1b4dfacd443148279fffd16a39ec22908f75f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/plugin/qlibrary.cpp')
-rw-r--r--src/corelib/plugin/qlibrary.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index ee81b32bfb..befe784c05 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2018 Intel Corporation.
+** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -182,9 +182,7 @@ QT_BEGIN_NAMESPACE
\sa loadHints
*/
-
-static qsizetype qt_find_pattern(const char *s, qsizetype s_len,
- const char *pattern, ulong p_len)
+static qsizetype qt_find_pattern(const char *s, qsizetype s_len)
{
/*
We used to search from the end of the file so we'd skip the code and find
@@ -195,8 +193,8 @@ static qsizetype qt_find_pattern(const char *s, qsizetype s_len,
More importantly, the pattern string may exist in the debug information due
to it being used in the plugin in the first place.
*/
-
- static const QByteArrayMatcher matcher(QByteArray(pattern, p_len));
+ QByteArrayView pattern = QPluginMetaData::MagicString;
+ static const QByteArrayMatcher matcher(pattern.toByteArray());
return matcher.indexIn(s, s_len);
}
@@ -278,10 +276,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
}
#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
- char pattern[] = "qTMETADATA ";
- pattern[0] = 'Q'; // Ensure the pattern "QTMETADATA" is not found in this library should QPluginLoader ever encounter it.
- const ulong plen = ulong(qstrlen(pattern));
- if (qsizetype rel = qt_find_pattern(filedata + r.pos, r.length, pattern, plen);
+ if (qsizetype rel = qt_find_pattern(filedata + r.pos, r.length);
rel >= 0) {
const char *data = filedata + r.pos + rel;
QString errMsg;