vector subscript out of range assertion hit on windows

Bug #1020942 reported by Dennis Knochenwefel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
Undecided
Paul J. Lucas

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.

Related branches

Changed in zorba:
status: New → In Progress
Changed in zorba:
status: In Progress → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.