Project

Profile

Help

Bug #4716

size method of XdmValue returns random numbers

Added by O'Neil Delpratt 22 days ago. Updated 7 days ago.

Status:
Resolved
Priority:
Normal
Category:
C++ API
Start date:
2020-09-03
Due date:
% Done:

100%

Estimated time:
Found in version:
1.2.1
Fixed in version:

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

History

#1 Updated by O'Neil Delpratt 7 days ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied the the proposed fix on the Saxon/C 1.2 branch and on the trunk. Available for the next maintenance release.

Please register to edit this issue

Also available in: Atom PDF