Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

Webinar: C++ semantics - 06.11

>
>
>
Examples of errors detected by the V505…

Examples of errors detected by the V505 diagnostic

V505. The 'alloca' function is used inside the loop. This can quickly overflow stack.


Crystal Space 3D SDK

V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. applighter2 scene.cpp 942


#define CS_ALLOC_STACK_ARRAY(type, var, size) \
  type *var = (type *)alloca ((size) * sizeof (type))

void Scene::PropagateLight (....)
{
  ....
  PortalRefArray::Iterator it =
    sourceSector->allPortals.GetIterator ();
  while (it.HasNext ())
  {
    ....
    CS_ALLOC_STACK_ARRAY(csVector3,
      tmpVertices, portal->worldVertices.GetSize ());
    ....
  }
}

Multi-threaded Dynamic Queue

V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. GridCtrl gridctrl.cpp 2332


COleDataSource* CGridCtrl::CopyTextFromGrid()
{
  ....
  for (int row = Selection.GetMinRow();
    row <= Selection.GetMaxRow(); row++)
  {
    ....
    sf.Write(T2A(str.GetBuffer(1)), str.GetLength());
    ....
  }
  ....
}

This code is potentially dangerous. T2A() macro uses alloca() function. As alloca() function is called from within the loop, it can quickly lead to stack overflow.


Pixie

V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. ri polygons.cpp 1120


inline  void  triangulatePolygon(....) {
  ....
  for (i=1;i<nloops;i++) {
    ....
    do {
      ....
      do {
        ....
        CTriVertex *snVertex =
          (CTriVertex *) alloca(2*sizeof(CTriVertex));
        ....
      } while(dVertex != loops[0]);
      ....
    } while(sVertex != loops[i]);
    ....
  }
  ....
}

DeSmuME

V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. DeSmuME_VS2005 7zip.cpp 161


ArchiveFile::ArchiveFile(const char* filename)
{
  ....
  for(size_t i = 0;
      i < s_formatInfos.size() && m_typeIndex < 0;
      i++)
  {
    ....
    char* fileSig = (char*)_alloca(len);
    ....
  }
  ....
}

Synergy

V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. rijndael.cpp 1206


size_t Rijndael::Enc::AdvancedProcessBlocks(....) const
{
  ....
  do {
    space = (byte *)alloca(255+sizeof(Locals));
    space += (256-(size_t)space%256)%256;
  }
  while (AliasedWithTable(space, space+sizeof(Locals)));
  ....
}

Similar errors can be found in some other places:

  • V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. cmswindowsscreensaver.cpp 398

Tizen

V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. audio_io_test.c 247


int audio_io_loopback_in_test()
{
  ....
  while (1) {
    char *buffer = alloca(size);
    if ((ret = audio_in_read(input, (void *)buffer, size)) >
                                           AUDIO_IO_ERROR_NONE) {
      fwrite(buffer, size, sizeof(char), fp);
      printf("PASS, size=%d, ret=0x%x\n", size, ret);
    } else {
      printf("FAIL, size=%d, ret=0x%x\n", size, ret);
    }
  }
  ....
}

EFL Core Libraries

V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. evas_font_dir.c 129


static Eina_List *
evas_font_set_get(const char *name)
{
  ....
  const char *pp;
  char *nm;
  pp = name;
  while (p)
  {
    nm = alloca(p - pp + 1);
    strncpy(nm, pp, p - pp);
    nm[p - pp] = 0;
    fonts = eina_list_append(fonts, eina_stringshare_add(nm));
    pp = p + 1;
    p = strchr(pp, ',');
    if (!p) fonts = eina_list_append(fonts,
                                     eina_stringshare_add(pp));
  }
  ....
}

Similar errors can be found in some other places:

  • V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. eina_benchmark.c 285
  • V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. eina_module.c 547
  • V505 The 'alloca' function is used inside the loop. This can quickly overflow stack. eldbus_message_from_eina_value.c 327
  • And 21 additional diagnostic messages.