From 0de58ecbd507ef4a5e97a9b560e5c81896fba614 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 28 Apr 2025 16:12:24 +1000 Subject: [PATCH] connect engine: correct two uninitalized variable errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit storage/connect/tabxml.cpp:1616:46: warning: ‘*this.XMLCOL::Long’ may be used uninitialized [-Wmaybe-uninitialized] 1616 | Valbuf = (char*)PlugSubAlloc(g, NULL, n * (Long + 1)); In this case we are overriding the class 3 lines earlier. Add some constructs to preserve the value of Long as the old class being replaced with a new subclass. storage/connect/filter.cpp:1594:13: warning: ‘*this.FILTERCMP::FILTERX.FILTERX::FILTER.FILTER::Opc’ is used uninitialized [-Wuninitialized] 1594 | Bt = OpBmp(g, Opc); The construction of FILTERCMP has an Opc(ode) and this should be passed rather than relying on the uninitialized value of the parent class. Also save its value in the class. --- storage/connect/filter.cpp | 5 +++-- storage/connect/filter.h | 2 +- storage/connect/tabxml.cpp | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index cddb8b8c526..9e9a526792f 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -1179,7 +1179,7 @@ bool FILTER::Convert(PGLOBAL g, bool having) case OP_GT: case OP_GE: case OP_LT: - case OP_LE: new(this) FILTERCMP(g); break; + case OP_LE: new(this) FILTERCMP(g, Opc); break; case OP_AND: new(this) FILTERAND; break; case OP_OR: new(this) FILTEROR; break; case OP_NOT: new(this) FILTERNOT; break; @@ -1589,8 +1589,9 @@ void FILTER::Prints(PGLOBAL g, char *ps, uint z) /***********************************************************************/ /* FILTERCMP constructor. */ /***********************************************************************/ -FILTERCMP::FILTERCMP(PGLOBAL g) +FILTERCMP::FILTERCMP(PGLOBAL g, OPVAL Opc) { + this->Opc= Opc; Bt = OpBmp(g, Opc); } // end of FILTERCMP constructor diff --git a/storage/connect/filter.h b/storage/connect/filter.h index 8f973b52cd0..1007e9b3bd9 100644 --- a/storage/connect/filter.h +++ b/storage/connect/filter.h @@ -120,7 +120,7 @@ class FILTERX : public FILTER { class FILTERCMP : public FILTERX { public: // Constructor - FILTERCMP(PGLOBAL g); + FILTERCMP(PGLOBAL, OPVAL); // Methods bool Eval(PGLOBAL) override; diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index bc2ebb6e581..c09c32e65a7 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -1611,7 +1611,9 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode) if (Tdbp->Xpand) n = Tdbp->Limit; + auto oLong = Long; new(this) XMULCOL(Value); // Change the class of this column + Long = oLong; } // endif Inod Valbuf = (char*)PlugSubAlloc(g, NULL, n * (Long + 1));