# Examples of errors detected by the V521 diagnostic

**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 (¶ms[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;
....
}
```

0