summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qdebug.cpp7
-rw-r--r--src/corelib/io/qdebug_p.h2
2 files changed, 5 insertions, 4 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;
diff --git a/src/corelib/io/qdebug_p.h b/src/corelib/io/qdebug_p.h
index 1dead0f47d..810fc3b4b6 100644
--- a/src/corelib/io/qdebug_p.h
+++ b/src/corelib/io/qdebug_p.h
@@ -25,7 +25,7 @@ QT_BEGIN_NAMESPACE
namespace QtDebugUtils {
-Q_CORE_EXPORT QByteArray toPrintable(const char *data, int len, int maxSize);
+Q_CORE_EXPORT QByteArray toPrintable(const char *data, qint64 len, qsizetype maxSize);
// inline helpers for formatting basic classes.