From 65db9a0253e1b132eee14ce22772c4179b545e13 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Thu, 2 Jan 2025 14:46:32 +0100 Subject: [PATCH] Fix index check Also fixes handling of empty netrc. Signed-off-by: Fredrik Eriksson --- src/cmd/netrcparser.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cmd/netrcparser.cpp b/src/cmd/netrcparser.cpp index 15417e134..f9b95c762 100644 --- a/src/cmd/netrcparser.cpp +++ b/src/cmd/netrcparser.cpp @@ -56,6 +56,9 @@ bool NetrcParser::parse() return false; } QString content = netrc.readAll(); + if (content.isEmpty()) { + return false; + } auto tokens = content.split(QRegularExpression("\\s+")); @@ -71,9 +74,9 @@ bool NetrcParser::parse() } i++; - if (i > tokens.count()) { + if (i >= tokens.count()) { qDebug() << "error fetching value for" << key; - return false; + break; } auto value = tokens[i]; -- 2.30.2