From 168533ee78450a676e379f0cbdac9e1d2384a151 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 14 Dec 2018 09:28:41 +0100 Subject: [PATCH] Debugger: Fix array type element count extraction Task-number: QTCREATORBUG-20639 Task-number: QTCREATORBUG-21677 Change-Id: I518ba2a8afde099535becd3af9bed4ded1b54644 Reviewed-by: hjk Reviewed-by: Christian Stenger --- src/libs/qtcreatorcdbext/pytype.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libs/qtcreatorcdbext/pytype.cpp b/src/libs/qtcreatorcdbext/pytype.cpp index ec677718241..bd08c4b789f 100644 --- a/src/libs/qtcreatorcdbext/pytype.cpp +++ b/src/libs/qtcreatorcdbext/pytype.cpp @@ -105,9 +105,11 @@ static bool isArrayType(const std::string &typeName) static ULONG extractArraySize(const std::string &typeName, size_t openArrayPos = 0) { if (openArrayPos == 0) - openArrayPos = typeName.find_last_of('['); - const auto closeArrayPos = typeName.find_last_of(']'); - if (openArrayPos == std::string::npos || closeArrayPos == std::string::npos) + openArrayPos = typeName.find_first_of('['); + if (openArrayPos == std::string::npos) + return 0; + const auto closeArrayPos = typeName.find_first_of(']', openArrayPos); + if (closeArrayPos == std::string::npos) return 0; const std::string arraySizeString = typeName.substr(openArrayPos + 1, closeArrayPos - openArrayPos - 1);