...
Code Block |
---|
...
size_t size = strlen(input_str);
if (size == SIZE_MAX) {
/* Handle Error */
}
str = malloc(size+1);
strcpy(str, input_str);
...
|
Note that in accordance with rule MEM35-C. Ensure that size arguments to memory allocation functions are valid the argument supplied to malloc()
is checked to ensure an numeric overflow does not occur.
...