Language: Go
Label: vulnerable
CWE: CWE-1284 \u2014 Improper Validation of Specified Quantity in Input
The product receives input that is expected to specify a quantity (such as size or length), but it does not validate or incorrectly validates that the quantity has the required properties.

Code:
func BenchmarkOnes(t *testing.B) {
	bf := NewBitfield(benchmarkSize)
	t.ResetTimer()
	for i := 0; i < t.N; i++ {
		for j := 0; j*4 < benchmarkSize; j++ {
			if bf.Ones() != j {
				t.Fatal("bad", i)
			}
			bf.SetBit(j * 4)
		}
		for j := 0; j*4 < benchmarkSize; j++ {
			bf.UnsetBit(j * 4)
		}
	}
}