Actions
Bug #4716
closedsize method of XdmValue returns random numbers
Start date:
2020-09-03
Due date:
% Done:
100%
Estimated time:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
1.2.1
Fixed in version:
11.1
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:
Description
Reported user:
The size
method of XdmValue returns random numbers. This happens when we use the constructor XdmValue(SaxonProcessor *)
because we fail to set the attribute variable xdmSize =0
Sample code:
//add XML transformation params if necessary
XdmValue * values = new XdmValue(processor);
values->addXdmItem((XdmItem*)processor->makeIntegerValue(10));
trans->setParameter("values",(XdmValue *)values);
XdmValue * values1 = new XdmValue(processor);
values1->addXdmItem((XdmItem*)processor->makeIntegerValue(5));
values1->addXdmItem((XdmItem*)processor->makeStringValue("Test-Test"));
trans->setParameter("values1",(XdmValue *)values1);
std::map<std::string, XdmValue*> params = trans->getParameters();
for( auto const& [key, val] : params )
{
for ( auto i = 0; i < val->size(); i++) {
std::cout << key // string (key)
<< ':'
<< val->itemAt(i)->getStringValue()
<< std::endl ;
}
}
Proposed fix:
XdmValue() {
initialize();
}
XdmValue(SaxonProcessor * p) {
initialize();
proc = p;
}
protected:
inline void initialize() noexcept {
jValues = nullptr;
proc = nullptr;
refCount = 1;
valueType = nullptr;
xdmSize = 0;
}
Please register to edit this issue
Actions