Examples of errors detected by the V533 diagnostic
V533. It is possible that a wrong variable is incremented inside the 'for' operator. Consider inspecting 'X'.
Doom 3
V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'j'. idLib surface_polytope.cpp 65
void idSurface_Polytope::FromPlanes(....)
{
....
for ( j = 0; j < w.GetNumPoints(); j++ ) {
for ( k = 0; k < verts.Num(); j++ ) {
if ( verts[k].xyz.Compare(w[j].ToVec3(),
POLYTOPE_VERTEX_EPSILON ) ) {
break;
}
}
....
}
....
}
This is what should have been written here: for ( k = 0; k < verts.Num(); k++ ).
Simple DirectMedia Layer
V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. testshape testshape.c 130
int main(int argc,char** argv)
{
....
for(i=0;i<num_pictures;i++) {
pictures[i].texture = SDL_CreateTextureFromSurface(....);
if(pictures[i].texture == NULL) {
j = 0;
for(j=0;j<num_pictures;i++) // <=
if(pictures[i].texture != NULL)
SDL_DestroyTexture(pictures[i].texture);
for(i=0;i<num_pictures;i++)
SDL_FreeSurface(pictures[i].surface);
....
}
}
....
}
Godot Engine
V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. scene_preloader.cpp 410
Dictionary ScenePreloader::_get_bundled_scene() const
{
....
Vector<int> rconns;
....
for(int i=0;i<connections.size();i++)
{
....
for(int j=0;j<cd.binds.size();i++)
rconns.push_back(cd.binds[j]);
}
....
}
Unreal Engine 4
V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'LineIdx'. internationalizationexportcommandlet.cpp 661
bool FPortableObjectFormatDOM::FromString( const FString& InStr )
{
....
for( uint32 NextLineIdx = LineIdx + 1; // <=
NextLineIdx < NumFileLines &&
LinesToProcess[NextLineIdx].Trim().TrimTrailing()....;
++LineIdx ) // <=
{
....
}
....
}
This is what should have been written here: ++NextLineIdx.
Open X-Ray Engine
V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. mxqmetric.cpp 76
MxMatrix& MxQuadric::homogeneous(MxMatrix& H) const
{
....
unsigned int i, j;
for(i=0; i<A.dim(); i++) for(j=0; j<A.dim(); i++)
H(i,j) = A(i,j);
....
}
LibreOffice
V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. javatypemaker.cxx 602
void printConstructors(....)
{
....
for (std::vector<
unoidl::SingleInterfaceBasedServiceEntity::Constructor::
Parameter >::const_iterator j(i->parameters.begin());
j != i->parameters.end(); ++i)
{
o << ", ";
printType(o, options, manager, j->type, false);
if (j->rest) {
o << "...";
}
o << ' '
<< codemaker::java::translateUnoToJavaIdentifier(
u2b(j->name), "param");
}
....
}
GTK
V533 [CWE-691] It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. gskvulkanimage.c 721
void
gsk_vulkan_image_upload_regions (GskVulkanImage *self,
GskVulkanUploader *uploader,
guint num_regions,
GskImageRegion *regions)
{
....
for (int i = 0; i < num_regions; i++)
{
m = mem + offset;
if (regions[i].stride == regions[i].width * 4)
{
memcpy (m, regions[i].data, regions[i].stride * regions[i].height);
}
else
{
for (gsize r = 0; r < regions[i].height; i++)
memcpy (m + r * regions[i].width * 4,
regions[i].data + r * regions[i].stride,
regions[i].width * 4);
}
....
}
....
}
Chromium
V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'it'. tree_synchronizer.cc 143
template <typename Iterator>
static void PushLayerPropertiesInternal(Iterator source_layers_begin,
Iterator source_layers_end,
LayerTreeHost* host_tree,
LayerTreeImpl* target_impl_tree)
{
for (Iterator it = source_layers_begin; it != source_layers_end; ++it)
{
auto* source_layer = *it;
....
if (!target_layer) {
bool host_set_on_source =
source_layer->layer_tree_host() == host_tree;
bool source_found_by_iterator = false;
for (auto host_tree_it = host_tree->begin();
host_tree_it != host_tree->end(); ++it) // <=
{
if (*host_tree_it == source_layer)
{
source_found_by_iterator = true;
break;
}
}
....
}
....
}
}