Fix undefined behavior in ProString/ProKey::appendTo
We must not pass null pointers to memcpy. Fixes: QTBUG-88780 Change-Id: Ic1d77b4672310a3f6d0d4fbee5f2889e3e4d219d Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 21e77772309df0f2c3fc15f16f9a95214d13f91c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
676b912cf9
commit
96ea154b0f
@ -233,6 +233,8 @@ template <> struct QConcatenable<ProString> : private QAbstractConcatenable
|
||||
static inline void appendTo(const ProString &a, QChar *&out)
|
||||
{
|
||||
const auto n = a.size();
|
||||
if (!n)
|
||||
return;
|
||||
memcpy(out, a.toQStringView().data(), sizeof(QChar) * n);
|
||||
out += n;
|
||||
}
|
||||
@ -247,6 +249,8 @@ template <> struct QConcatenable<ProKey> : private QAbstractConcatenable
|
||||
static inline void appendTo(const ProKey &a, QChar *&out)
|
||||
{
|
||||
const auto n = a.size();
|
||||
if (!n)
|
||||
return;
|
||||
memcpy(out, a.toQStringView().data(), sizeof(QChar) * n);
|
||||
out += n;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user