[pim/libkleo/gpg4win/gpd-5.2] autotests: Fix logic error in EnvironmentVariableOverride helper

Ingo Klöcker <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 2de8a420a65d6fc6524a7913e44a0330bbb0793d by Ingo Klöcker, on behalf of Ingo Klöcker.
Committed on 30/07/2026 at 09:39.
Pushed by kloecker into branch 'gpg4win/gpd-5.2'.

Fix logic error in EnvironmentVariableOverride helper

...and initialize mWasSet to avoid maybe-uninitialized warning

(cherry picked from commit ebb7c849d5953288376c8ee15d42a45567f9d15e)

M  +2    -2    autotests/formattingtest.cpp

https://invent.kde.org/pim/libkleo/-/commit/2de8a420a65d6fc6524a7913e44a0330bbb0793d

diff --git a/autotests/formattingtest.cpp b/autotests/formattingtest.cpp
index e5ec6f33..f992aae9 100644
--- a/autotests/formattingtest.cpp
+++ b/autotests/formattingtest.cpp
@@ -130,7 +130,7 @@ public:
 
     void set(const char *varName, QByteArrayView value)
     {
-        if (mVarName.isEmpty()) {
+        if (!mVarName.isEmpty()) {
             reset();
         }
         mWasSet = qEnvironmentVariableIsSet(varName);
@@ -156,7 +156,7 @@ public:
 
 private:
     QByteArray mVarName;
-    bool mWasSet;
+    bool mWasSet = false;
     QString mOldValue;
 };
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.