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