diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-08-17 16:58:09 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-08-21 08:28:44 +0200 |
commit | bcc32bc1128544cceb41d337ee16bc36c3eb188f (patch) | |
tree | 9d6a92f36d792547d9ad771decfb3abce9054bd3 /src/corelib/io/qdebug.cpp | |
parent | 52c5f286950a56a8714a0be9b8ecb088f07d7eb8 (diff) |
Port QtDebugUtils::toPrintable() to qint64/qsizetype
Some callers pass qint64 arguments to the len parameter, so take the
size as qint64, not qsizetype, to avoid silent truncation.
Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-103525
Change-Id: I4bc5673297f24aea0cfc9d20887dc8a877743214
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/io/qdebug.cpp')
-rw-r--r-- | src/corelib/io/qdebug.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 524a04456a..54b2d605e6 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -24,15 +24,16 @@ using QtMiscUtils::fromHex; /* Returns a human readable representation of the first \a maxSize - characters in \a data. + characters in \a data. The size, \a len, is a 64-bit quantity to + avoid truncation due to implicit conversions in callers. */ -QByteArray QtDebugUtils::toPrintable(const char *data, int len, int maxSize) +QByteArray QtDebugUtils::toPrintable(const char *data, qint64 len, qsizetype maxSize) { if (!data) return "(null)"; QByteArray out; - for (int i = 0; i < qMin(len, maxSize); ++i) { + for (qsizetype i = 0; i < qMin(len, maxSize); ++i) { char c = data[i]; if (isprint(c)) { out += c; |