why is this giving segmentation fault?
int space_needed = 0;
for (int i = 3; i < cmd_argc; i++) {
    space_needed += strlen(cmd_argv[i]) + 1;
}

printf("before space!\n");
char *contents = malloc(space_needed);
if (contents == NULL) {
    perror("malloc");
    exit(1);
}

printf("after malloc!\n");
strcpy(contents, cmd_argv[3]);
for (int i = 3; i < cmd_argc; i++) {
    strcat(contents, " ");
    strcat(contents, cmd_argv[i]);
}
