← Back to team overview

zorba-coders team mailing list archive

[Bug 1020942] [NEW] vector subscript out of range assertion hit on windows

 

Public bug reported:

in src/zorbatypes/binary.cpp a lot of vectors are accessed with [0],
e.g.:

    aBase64.theData.resize(
      copy_without_ws( aString, aLength, &aBase64.theData[0] )
    );

if in this case aLength is of size 0 the assertion "vector subscript out
of range" is hit on windows in debug build. This happens because size ==
pos in std::vector implementation on windows:

  reference operator[](size_type _Pos)
		{	// subscript mutable sequence
   #if _ITERATOR_DEBUG_LEVEL == 2
		if (size() <= _Pos)
			{	// report error
			_DEBUG_ERROR("vector subscript out of range");
			_SCL_SECURE_OUT_OF_RANGE;
			}

Therefore, before accessing a vector with [0] one must check whether the
size of the vector is > 0. Otherwise the mentioned assertion will
trigger.

** Affects: zorba
     Importance: Undecided
     Assignee: Paul J. Lucas (paul-lucas)
         Status: New


** Tags: incorrect-result

-- 
You received this bug notification because you are a member of Zorba
Coders, which is the registrant for Zorba.
https://bugs.launchpad.net/bugs/1020942

Title:
  vector subscript out of range assertion hit on windows

Status in Zorba - The XQuery Processor:
  New

Bug description:
  in src/zorbatypes/binary.cpp a lot of vectors are accessed with [0],
  e.g.:

      aBase64.theData.resize(
        copy_without_ws( aString, aLength, &aBase64.theData[0] )
      );

  if in this case aLength is of size 0 the assertion "vector subscript
  out of range" is hit on windows in debug build. This happens because
  size == pos in std::vector implementation on windows:

    reference operator[](size_type _Pos)
  		{	// subscript mutable sequence
     #if _ITERATOR_DEBUG_LEVEL == 2
  		if (size() <= _Pos)
  			{	// report error
  			_DEBUG_ERROR("vector subscript out of range");
  			_SCL_SECURE_OUT_OF_RANGE;
  			}

  Therefore, before accessing a vector with [0] one must check whether
  the size of the vector is > 0. Otherwise the mentioned assertion will
  trigger.

To manage notifications about this bug go to:
https://bugs.launchpad.net/zorba/+bug/1020942/+subscriptions


Follow ups

References