...
Calling malloc(s)
allocates memory for an object whose size is s
and returns either a null NULL pointer or a pointer to the allocated memory. A program can implicitly convert the pointer that malloc()
returns into a different pointer type.
...
Code Block | ||
---|---|---|
| ||
enum month { Jan, Feb, /* ... */ }; typedef enum month month; typedef struct date date; struct date { unsigned char dd; month mm; unsigned yy; }; typedef struct string string; struct string { size_t length; char text[]; }; date *d, *week, *fortnight; string *name; d = MALLOC(date); week = MALLOC_ARRAY(7, date); name = MALLOC_FLEX(string, 16, char); fortnight = CALLOC(14, date); |
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MEM02-A | 1 ( low ) 1 ( | unlikely ) | 3 ( low ) | P3 | L3 |
Automated Detection
The LDRA tool suite V 7.6.0 is able to detect violations of this recommendation.
...