To get a trial key
fill out the form below
Team License (standard version)
Enterprise License (extended version)
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
Examples of errors detected by the V521…

Examples of errors detected by the V521 diagnostic

April 5, 2021

V521. Such expressions using the ',' operator are dangerous. Make sure the expression is correct.


G3D Content Pak

V521 Such expressions using the ',' operator are dangerous. Make sure the expression '0, 0' is correct. graphics3D anyval.cpp 275


void AnyVal::serialize(G3D::TextOutput& t) const {
  ....
  const Matrix3& m = *(Matrix3*)m_value;
  ....
  t.printf("%10.5f, %10.5f, %10.5f,\n"
           "%10.5f, %10.5f, %10.5f,\n"
           "%10.5f, %10.5f, %10.5f)",
           m[0, 0], m[0, 1], m[0, 2],
           m[1, 0], m[1, 1], m[1, 2],
           m[2, 0], m[2, 1], m[2, 2]);
  ....
}

This is what should have been written here: ...., m[0][0], m[0][1], ....


Lugaru

V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'bleedx = 0, bleedy' is correct. Lugaru person.cpp 7815


Person::Person()
{
  ....
  bleeding = 0;
  bleedx = 0,bleedy;
  direction = 0;
  ....
}

This is what should have been written here: bleedy = 0;


Quake-III-Arena

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. bspc l_bsp_q1.c 136


void Q1_AllocMaxBSP(void)
{
  ....
  q1_allocatedbspmem +=
    Q1_MAX_MAP_CLIPNODES * sizeof(q1_dclipnode_t);
  ....
  q1_allocatedbspmem +=
    Q1_MAX_MAP_EDGES , sizeof(q1_dedge_t);          // <=
  ....
  q1_allocatedbspmem +=
    Q1_MAX_MAP_MARKSURFACES * sizeof(unsigned short);
  ....
}

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. bspc l_bsp_hl.c 154

IPP Samples

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. vc1_dec umc_vc1_dec_mb_com.cpp 370


void GetIntraDCPredictors(VC1Context* pContext)
{
  DCPred.DC[13] = pC->DCBlkPred[5].DC,QurrQuant;
  ....
}

IPP Samples

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. speech usc_dtmf.c 309


static int DTMF_16s(const Ipp16s *pBuffer, int nbytes,
                    USC_ToneID *toneRes,
                    DTMFState_16s *pIppTDParams)
{
  ....
  for (i = pIppTDParams->dtmf_fs, j = 0;
       i < dtmf_frame_size+pIppTDParams->dtmf_fs, j < nbytes;
       i++, j++)
  ....
}

The && operator should be used in the loop condition.


Trans-Proteomic Pipeline

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. tpplib peptide.cpp 191


bool Peptide::operator==(Peptide& p) {
  ....
  for (i = 0, j = 0;
       i < this->stripped.length(), j < p.stripped.length();
       i++, j++) {
  ....
}

The && operator should be used in the loop condition.

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. tpplib peptide.cpp 243

Visualization Toolkit (VTK)

V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'this->Internal->TableArrays[i], name' is correct. vtkIO vtksesamereader.cxx 352


int vtkSESAMEReader::GetTableArrayStatus(const char* name)
{
  ....
  for(i=0; i<numArrays; i++)
  {
    if(this->Internal->TableArrays[i], name)     // <=
    {
      return this->Internal->TableArrayStatus[i];
    }
  }
  return 0;
}

OpenSSL

V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'al = 2, 50' is correct. s3_clnt.c 1714


#define SSL3_AL_FATAL 2
#define SSL_AD_DECODE_ERROR 50

int ssl3_get_new_session_ticket(SSL *s)
{
  int al;
  ....
  al = SSL3_AL_FATAL, SSL_AD_DECODE_ERROR;
  ....
}

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'al = 2, 50' is correct. s3_clnt.c 1724

Trans-Proteomic Pipeline

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. spectrastpeaklist.cpp 504


double SpectraSTPeakList::calcDot(SpectraSTPeakList* other) {
  ....
  for (i = this->m_bins->begin(), j = other->m_bins->begin();
       i != this->m_bins->end(), j != other->m_bins->end();
       i++, j++) {
    d = (*i) * (*j);
    dot += d;
  }
  ....
}

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. spectrastpeaklist.cpp 516
  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. spectrastpeaklist.cpp 529
  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. spectrastpeaklist.cpp 592
  • And 3 additional diagnostic messages.

CryEngine 3 SDK

V521 Such expressions using the ',' operator are dangerous. Make sure the expression '"%s:", currentSeat->GetSeatName()' is correct. flowvehiclenodes.cpp 662


virtual void ProcessEvent( .... )
{
  ....
  string pMessage = ("%s:", currentSeat->GetSeatName());
  ....
}

This is what should have been written here: string pMessage = string().Format("%s:", currentSeat->GetSeatName());

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. flowvehiclenodes.cpp 672

Grassroots DICOM library (GDCM)

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. gdcmsorter.cxx 82


bool Sorter::StableSort(
  std::vector<std::string> const & filenames)
{
  ....
  std::vector< SmartPointer<FileWithName> >::iterator
    it2 = filelist.begin();

  for( Directory::FilenamesType::const_iterator it =
         filenames.begin();
       it != filenames.end(), it2 != filelist.end();
       ++it, ++it2)
  {
  ....
}

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. gdcmsorter.cxx 123

Oracle VM Virtual Box

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. applianceimplimport.cpp 3943


void Appliance::i_importMachines(....)
{
  ....
  /* Iterate through all virtual systems of that appliance */
  size_t i = 0;
  for (it = reader.m_llVirtualSystems.begin(),
       it1 = m->virtualSystemDescriptions.begin();
       it != reader.m_llVirtualSystems.end(),         // <=
       it1 != m->virtualSystemDescriptions.end();
       ++it, ++it1, ++i)
  {....}
  ....
}

Unreal Engine 4

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. unrealaudiodevicewasapi.cpp 128


static void GetArrayOfSpeakers(....)
{
  Speakers.Reset();
  uint32 ChanCount = 0;
  // Build a flag field of the speaker outputs of this device
  for (uint32 SpeakerTypeIndex = 0;
       SpeakerTypeIndex < ESpeaker::SPEAKER_TYPE_COUNT,    // <=
       ChanCount < NumChannels; ++SpeakerTypeIndex)
  {
    ....
  }

  check(ChanCount == NumChannels);
}

Oracle VM Virtual Box

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. vboxmpwddm.cpp 1083


NTSTATUS DxgkDdiStartDevice(...)
{
  ....
  if ( ARGUMENT_PRESENT(MiniportDeviceContext) &&
        ARGUMENT_PRESENT(DxgkInterface) &&
        ARGUMENT_PRESENT(DxgkStartInfo) &&
        ARGUMENT_PRESENT(NumberOfVideoPresentSources), // <=
        ARGUMENT_PRESENT(NumberOfChildren)
        )
  {
    ....
  }
  ....
}

ReactOS

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. cmdcons.c 430


static INT CommandDumpSector(....)
{
   ....
   SectorCount.QuadPart = DiskGeometry.Cylinders.QuadPart *
                          DiskGeometry.TracksPerCylinder,  // <=
                          DiskGeometry.SectorsPerTrack;
   ....
}

CryEngine V

V521 Such expressions using the ',' operator are dangerous. Make sure the expression '!sWords[iWord].empty(), iWord ++' is correct. TacticalPointSystem.cpp 3243


bool CTacticalPointSystem::Parse(....) const
{
  string sInput(sSpec);
  const int MAXWORDS = 8;
  string sWords[MAXWORDS];

  int iC = 0, iWord = 0;
  for (; iWord < MAXWORDS; !sWords[iWord].empty(), iWord++) // <=
  {
    sWords[iWord] = sInput.Tokenize("_", iC);
  }
  ....
}

CryEngine V

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. HommingSwarmProjectile.cpp 187


void CHommingSwarmProjectile::HandleEvent(....)
{
  ....
  explodeDesc.normal = -pCollision->n,pCollision->vloc[0];
  ....
}

Steinberg SDKs

V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'i < temp, i < numParams' is correct. mdaBaseProcessor.cpp 309


tresult PLUGIN_API BaseProcessor::setState (IBStream* state)
{
  ....
  // read each parameter
  for (uint32 i = 0; i < temp, i < numParams; i++)
  {
    state->read (&params[i], sizeof (ParamValue));
    SWAP64_BE(params[i])
  }
  ....
}

Steinberg SDKs

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. mdaBaseProcessor.cpp 142


bool BaseProcessor::bypassProcessing (ProcessData& data)
{
  ....
  for (int32 bus = 0; bus < data.numInputs,   // <=
                      bus < data.numOutputs; bus++)
  {
    ....
    if (data.numInputs <= bus ||
        data.inputs[bus].numChannels <= channel)
    {
      memset(data.outputs[bus].channelBuffers32[channel], ....);
      data.outputs[bus].silenceFlags |= (uint64)1 << channel;
    }
    else
    {
      ....
    }
    ....
  }
  ....
}

Amazon Lumberyard

V521 Such expressions using the ',' operator are dangerous. Make sure the expression '!sWords[iWord].empty(), iWord ++' is correct. tacticalpointsystem.cpp 3376


bool CTacticalPointSystem::Parse(....) const
{
  string sInput(sSpec);
  const int MAXWORDS = 8;
  string sWords[MAXWORDS];

  int iC = 0, iWord = 0;
  for (; iWord < MAXWORDS; !sWords[iWord].empty(), iWord++)
  {
      sWords[iWord] = sInput.Tokenize("_", iC);
  }
  ....
}

Azure Service Fabric

V521 CWE-480 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. ReplicatedStore.SecondaryPump.cpp 1231


ErrorCode
ReplicatedStore::SecondaryPump::ApplyOperationsWithRetry(....)
{
 ....
 if (errorMessage.empty())
 {
  errorMessage = L"error details missing: LSN={0}", operationLsn;

  Assert::TestAssert("{0}", errorMessage);
 }
 ....
}
WriteInfo(errorMessage, L"error ....: LSN={0}", operationLsn);

Godot Engine

V521 CWE-480 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. os_windows.cpp 776


LRESULT OS_Windows::WndProc(....) {
  ....
  BITMAPINFO bmi;
  ZeroMemory(&bmi, sizeof(BITMAPINFO));
  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  bmi.bmiHeader.biWidth = dib_size.x;
  bmi.bmiHeader.biHeight = dib_size.y;
  bmi.bmiHeader.biPlanes = 1;
  bmi.bmiHeader.biBitCount = 32;
  bmi.bmiHeader.biCompression = BI_RGB;
  bmi.bmiHeader.biSizeImage = dib_size.x, dib_size.y * 4;
  ....
}

Most likely this is what should be written here: bmi.bmiHeader.biSizeImage = dib_size.x * dib_size.y * 4;


Dlib

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. optimization_line_search.h 211


inline double poly_min_extrap (
    double f0,
    double d0,
    double x1,
    double f_x1,
    double x2,
    double f_x2
)
{
  DLIB_ASSERT(0 < x1 && x1 < x2,"Invalid inputs were given to this function.\n"
      << "x1: " << x1
      << "    x2: " << x2
      );
  matrix<double,2,2> m;
  matrix<double,2,1> v;

  const double aa2 = x2*x2;
  const double aa1 = x1*x1;
  m =  aa2,       -aa1,
      -aa2*x2, aa1*x1;
  v = f_x1 - f0 - d0*x1,
      f_x2 - f0 - d0*x2;
  ....
}

Popular related articles
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: 11.21.2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
The Last Line Effect

Date: 05.31.2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
Appreciate Static Code Analysis!

Date: 10.16.2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
Free PVS-Studio for those who develops open source projects

Date: 12.22.2018

Author: Andrey Karpov

On the New 2019 year's eve, a PVS-Studio team decided to make a nice gift for all contributors of open-source projects hosted on GitHub, GitLab or Bitbucket. They are given free usage of PVS-Studio s…
PVS-Studio ROI

Date: 01.30.2019

Author: Andrey Karpov

Occasionally, we're asked a question, what monetary value the company will receive from using PVS-Studio. We decided to draw up a response in the form of an article and provide tables, which will sho…
How PVS-Studio Proved to Be More Attentive Than Three and a Half Programmers

Date: 10.22.2018

Author: Andrey Karpov

Just like other static analyzers, PVS-Studio often produces false positives. What you are about to read is a short story where I'll tell you how PVS-Studio proved, just one more time, to be more atte…
PVS-Studio for Java

Date: 01.17.2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…
The way static analyzers fight against false positives, and why they do it

Date: 03.20.2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…
The Evil within the Comparison Functions

Date: 05.19.2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
Static analysis as part of the development process in Unreal Engine

Date: 06.27.2017

Author: Andrey Karpov

Unreal Engine continues to develop as new code is added and previously written code is changed. What is the inevitable consequence of ongoing development in a project? The emergence of new bugs in th…

Comments (0)

Next comments

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept