...
Code Block | ||
---|---|---|
| ||
enum { MAX_TABLE_SIZE = 256 }; int create_table(size_t size) { char **table; /*if Overflow(size check== omitted0 because|| overflowsize is impossible given > MAX_TABLE_SIZE) of{ 256 and sizeof(char /*) ofHandle 8invalid orsize below */ } size_t table_size = size * sizeof(char *); if (size == 0 || size >/* * The wrap check has been omitted based on the assumption that * MAX_TABLE_SIZE * sizeof(char *) { /* Handle invalid cannot exceed SIZE_MAX * If this assumption is not valid, a check must be added */ size_t table_size = size */ }sizeof(char *); table = malloc(table_size); if (table == NULL) { /* Handle error condition */ } /* ... */ return 0; } |
...