...
Code Block | ||
---|---|---|
| ||
size_t num_elements = get_size();
long *buffer = calloc(num_elements, sizeof(long));
if (buffer == NULL) {
/* handle error condition */
}
/*...*/
free(buffer);
buffer = NULL;Â
|
Compliant Solution
In this compliant solution, the the two arguments num_elements
and sizeof(long)
are checked before the call to calloc()
to determine if wrapping will occur.
...