Examples of errors detected by the V3106 diagnostic


V3106. Possibly index is out of bound.


FastReport

V3106 Possible negative index value. The value of 'idx' index could reach -1. BarcodeCodabar.cs 70


private int FindBarItem(string c)
{
  for (int i = 0; i < tabelle_cb.Length; i++)
  {
    if (c == tabelle_cb[i].c)
      return i;
  }
  return -1;
}

internal override string GetPattern()
{
  string result = tabelle_cb[FindBarItem("A")].data + "0";

  foreach (char c in text)
  {
    int idx = FindBarItem(c.ToString());
    result += tabelle_cb[idx].data + "0";
  }

  result += tabelle_cb[FindBarItem("B")].data;
  return result;
}


Bugs Found

Checked Projects
334
Collected Errors
12 668