Static Analysis Problem Type Reference
Storage was allocated whose size is not a multiple of the size of the pointed-to type.
A typical storage allocation operation requests a certain amount of storage and then assigns the resulting address to some pointer type. If the size of the pointed-to type is equal to the allocation size, then one object of the given type is allocated. If the allocation size is an even multiple of the size of the pointed-to type, then an array of objects of the given type is allocated. Other cases are malformed and are flagged with this error.
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
Allocation site |
The place where the memory was allocated |
#include <stdlib.h>
typedef struct {
int f1;
int f2;
int f3;
} s1;
typedef struct {
int f1;
int f2;
} s2;
int main(int argc, char **argv)
{
s2 *p = (s2 *) malloc( sizeof(s1) ); // probably intended sizeof(s2)
free(p);
return 0;
}