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
13200
13200
##### Example, bad
13201
13201
13202
13202
int a[10];
13203
- a[10] = 7; // bad
13203
+ a[10] = 7; // bad, array bounds overflow
13204
13204
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
13208
13207
13209
13208
##### Example, bad
13210
13209
13211
13210
int n = numeric_limits<int>::max();
13212
- int m = n + 1; // bad
13211
+ int m = n + 1; // bad, numeric overflow
13213
13212
13214
13213
##### Example, bad
13215
13214
13216
13215
int area(int h, int w) { return h * w; }
13217
13216
13218
- auto a = area(10'000'000, 100'000'000); // bad
13217
+ auto a = area(10'000'000, 100'000'000); // bad, numeric overflow
13219
13218
13220
13219
##### Exception
13221
13220
You can’t perform that action at this time.
0 commit comments