V627. Argument of sizeof() is a macro, which expands to a number. Consider inspecting the expression.
The analyzer has detected a potential error: a macro expanding into a number serves as an argument for the 'sizeof' operator. Using the operator in such a way can cause allocation of memory amount of incorrect size or other defects.
Consider an example:
#define NPOINT 100
...
char *point = (char *)malloc(sizeof(NPOINT));
Executing this code will result in allocation of insufficient memory amount. This is the correct code:
#define NPOINT 100
...
char *point = (char *)malloc(NPOINT);
This diagnostic is classified as:
You can look at examples of errors detected by the V627 diagnostic. |