} while (*token != '\0');
/* Add two here for the NULL terminating element and trace path */
- argv = malloc(sizeof(char *) * (num_opts + 2));
+ argv = zmalloc(sizeof(char *) * (num_opts + 2));
if (argv == NULL) {
goto error;
}
token = strtok(opts, " ");
while (token != NULL) {
argv[i] = strdup(token);
+ if (argv[i] == NULL) {
+ goto error;
+ }
token = strtok(NULL, " ");
i++;
}
size = sizeof(char *) * mem_len;
/* Add two here for the trace_path and the NULL terminating element. */
- argv = malloc(size);
+ argv = zmalloc(size);
if (argv == NULL) {
goto error;
}