Examples of errors detected by the V567 diagnostic

<< Return to list of all diagnostics

V567. Undefined behavior. The variable is modified while being used twice between sequence points.


Fennec Media

V567 Undefined behavior. The 'm_nCurrentBitIndex' variable is modified while being used twice at single sequence point. MACLib unbitarrayold.cpp 78


uint32 CUnBitArrayOld::DecodeValueRiceUnsigned(uint32 k)
{
  ...
  while (!(m_pBitArray[m_nCurrentBitIndex >> 5] &
     Powers_of_Two_Reversed[m_nCurrentBitIndex++ & 31])) {}
  ...
}

SAGA GIS

V567 Undefined behavior. The 'iFloater' variable is modified while being used twice between sequence points. shapes_lines line_simplification.cpp 248


bool CLine_Simplification::Simplify(
  CSG_Shape *pLine, int iPart, bool *Keep)
{
  ...
  Keep[iFloater--] = iAnchor == 0 && iFloater ==
    pLine->Get_Point_Count(iPart) - 1;
  ...
}

Miranda IM

V567 Undefined behavior. The 's' variable is modified while being used twice between sequence points. msn ezxml.c 371


short ezxml_internal_dtd(ezxml_root_t root, char *s,
  size_t len)
{
  ...
  while (*(n = ++s + strspn(s, EZXML_WS)) && *n != '>') {
  ...
}

It's not guaranteed that 's' will be incremented before calling the strspn function.


IPP Samples

V567 Undefined behavior. The 'pTemp' variable is modified while being used twice between sequence points. me umc_me_cost_func.h 168

V567 Undefined behavior. The 'pDst' variable is modified while being used twice between sequence points. me umc_me_cost_func.h 174


template<typename T, Ipp32s size> void HadamardFwdFast(
  ...., Ipp16s* pDst)
{
  Ipp32s *pTemp;
  ...
  for(j=0;j<4;j++) {
    a[0] = pTemp[0*4] + pTemp[1*4];
    a[1] = pTemp[0*4] - pTemp[1*4];
    a[2] = pTemp[2*4] + pTemp[3*4];
    a[3] = pTemp[2*4] - pTemp[3*4];
    pTemp = pTemp++;

    pDst[0*4] = (Ipp16s)(a[0] + a[2]);
    pDst[1*4] = (Ipp16s)(a[1] + a[3]);
    pDst[2*4] = (Ipp16s)(a[0] - a[2]);
    pDst[3*4] = (Ipp16s)(a[1] - a[3]);
    pDst = pDst++;
  }
  ...
}

Typical Undefined behavior!

Identical errors can be found in some other places:

  • V567 Undefined behavior. The 'pTemp' variable is modified while being used twice between sequence points. me umc_me_cost_func.h 219
  • V567 Undefined behavior. The 'pDst' variable is modified while being used twice between sequence points. me umc_me_cost_func.h 238

IPP Samples

V567 Undefined behavior. The 'm_curIndex' variable is modified while being used twice between sequence points. vc1_enc umc_vc1_enc_planes.h 630


bool MoveOnNextFrame()
{
  if (m_nFrames>0)
  {
    m_pFrame[m_curIndex] = 0;
    m_curIndex = (++m_curIndex)%m_maxN;
    m_nFrames--;
    return true;
  }
  return false;
}

IPP Samples

V567 Undefined behavior. The 'm_Quant.LimIQuant' variable is modified while being used twice between sequence points. vc1_enc umc_vc1_enc_brc_gop.cpp 241

V567 Undefined behavior. The 'm_Quant.IQuant' variable is modified while being used twice between sequence points. vc1_enc umc_vc1_enc_brc_gop.cpp 243


void VC1BRC_I::CompleteFrame(ePType picType)
{
  ...
  m_Quant.LimIQuant = m_Quant.LimIQuant--;
  ...
  m_Quant.IQuant = m_Quant.IQuant--;
  ...
}

Doom 3

V567 Undefined behavior. The 'dir_cache_index' variable is modified while being used twice between sequence points. TypeInfo filesystem.cpp 1877


int idFileSystemLocal::ListOSFiles(....)
{
  ...
  dir_cache_index = (++dir_cache_index) % MAX_CACHED_DIRS;
  ...
}

This is what should have been written here: dir_cache_index = (dir_cache_index + 1) % MAX_CACHED_DIRS;


ffdshow

V567 Undefined behavior. The 'm_Offset' variable is modified while being used twice between sequence points. quicksyncutils.h 257


inline bool PopFront(T& res, DWORD dwMiliSecs)
{
  ....
  m_Offset = ++m_Offset % m_Capacity;
  ....
}

<< Return to list of all diagnostics