connect engine: correct two uninitalized variable errors

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.
This commit is contained in:
Daniel Black 2025-04-28 16:12:24 +10:00
commit 0de58ecbd5
3 changed files with 6 additions and 3 deletions

View file

@ -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

View file

@ -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;

View file

@ -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));