...
Code Block | ||
---|---|---|
| ||
if (number > SIZE_MAX/sizeof(int)) {
/* handle overflow */
}
x = (int *)malloc(number * sizeof(int));
if (x == NULL) {
/* Handle Allocation Error */
}
/* ... */
if (error_condition == 1) {
/* Handle Error Condition*/
}
/* ... */
free(x);
x = NULL; 
|
Wiki Markup |
---|
Note that this solution checks for numeric overflow \[[INT32-C. Ensure that operations on signed integers do not result in overflow]\]. |
...