mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #1164 from ChrisGuzak/ChrisGuzak-sizeof-not_max
use sizeof(buffer) instead of MAX
This commit is contained in:
commit
644e0f5b5e
|
@ -1584,7 +1584,7 @@ Consider a famous security bug:
|
||||||
{
|
{
|
||||||
char buffer[MAX];
|
char buffer[MAX];
|
||||||
// ...
|
// ...
|
||||||
memset(buffer, 0, MAX);
|
memset(buffer, 0, sizeof(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
There was no postcondition stating that the buffer should be cleared and the optimizer eliminated the apparently redundant `memset()` call:
|
There was no postcondition stating that the buffer should be cleared and the optimizer eliminated the apparently redundant `memset()` call:
|
||||||
|
@ -1593,7 +1593,7 @@ There was no postcondition stating that the buffer should be cleared and the opt
|
||||||
{
|
{
|
||||||
char buffer[MAX];
|
char buffer[MAX];
|
||||||
// ...
|
// ...
|
||||||
memset(buffer, 0, MAX);
|
memset(buffer, 0, sizeof(buffer));
|
||||||
Ensures(buffer[0] == 0);
|
Ensures(buffer[0] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user