Project

Profile

Help

Bug #4716

closed

size method of XdmValue returns random numbers

Added by O'Neil Delpratt over 3 years ago. Updated about 2 years ago.

Status:
Closed
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:
11.1
Platforms:

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;
  }
Actions #1

Updated by O'Neil Delpratt over 3 years 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.

Actions #2

Updated by O'Neil Delpratt about 2 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 11.1

Bug fix patched in SaxonC 11.1 release

Please register to edit this issue

Also available in: Atom PDF