File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -13200,22 +13200,21 @@ Incrementing a value beyond a maximum value can lead to memory corruption and un
1320013200##### Example, bad
1320113201
1320213202 int a[10];
13203- a[10] = 7; // bad
13203+ a[10] = 7; // bad, array bounds overflow
1320413204
13205- int n = 0;
13206- while (n++ < 10)
13207- a[n - 1] = 9; // bad (twice)
13205+ for (int n = 0; n <= 10; ++n)
13206+ a[n] = 9; // bad, array bounds overflow
1320813207
1320913208##### Example, bad
1321013209
1321113210 int n = numeric_limits<int>::max();
13212- int m = n + 1; // bad
13211+ int m = n + 1; // bad, numeric overflow
1321313212
1321413213##### Example, bad
1321513214
1321613215 int area(int h, int w) { return h * w; }
1321713216
13218- auto a = area(10'000'000, 100'000'000); // bad
13217+ auto a = area(10'000'000, 100'000'000); // bad, numeric overflow
1321913218
1322013219##### Exception
1322113220
You can’t perform that action at this time.
0 commit comments