From fbc005706ce939804b154b75cc1640ceac4d042d Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Tue, 14 Dec 2010 15:48:41 +0100 Subject: [PATCH] debugger: Checking size of array in qDumpQByteArray --- share/qtcreator/gdbmacros/gdbmacros.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index 665231f4fa..be086693fe 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -1196,26 +1196,30 @@ static void qDumpQByteArray(QDumper &d) qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid const QByteArray &ba = *reinterpret_cast(d.data); + const int size = ba.size(); + if (size < 0) + return; + if (!ba.isEmpty()) { qCheckAccess(ba.constData()); - qCheckAccess(ba.constData() + ba.size()); + qCheckAccess(ba.constData() + size); } d.beginItem("value"); - if (ba.size() <= 100) + if (size <= 100) d.put(ba); else - d.put(ba.left(100)).put(" "); + d.put(ba.left(100)).put(" "); d.endItem(); d.putItem("valueencoded", "1"); d.putItem("type", NS"QByteArray"); - d.putItem("numchild", ba.size()); + d.putItem("numchild", size); if (d.dumpChildren) { d.putItem("childtype", "char"); d.putItem("childnumchild", "0"); d.beginChildren(); char buf[20]; - for (int i = 0; i != ba.size(); ++i) { + for (int i = 0; i != size; ++i) { unsigned char c = ba.at(i); unsigned char u = (isprint(c) && c != '\'' && c != '"') ? c : '?'; sprintf(buf, "%02x (%u '%c')", c, c, u); -- 2.11.0