why is this giving segmentation fault?


int read_from(User *users, Client *c, User **head) {
    int fd = c->fd;

    char *input = partial_read(c);
    int num_read = 0;

    if (input == NULL) {
        return fd;
    }

    num_read = strlen(input);
    input[num_read] = '\0';

    if (strlen(input) > 0 && (strcmp(input, "read") != 0)) {
        if (c->username == NULL) {
            int create = process_name(c, input, head);
            if (create != 0) {
                free(input);
                return create;
            }
        } else {
            char *cmd_argv[INPUT_ARG_MAX_NUM];

            for (int i = 0; i < INPUT_ARG_MAX_NUM; i++) {
                cmd_argv[i] = NULL;
            }

            int cmd_argc = tokenize2(input, cmd_argv);

            char *res = process_args(cmd_argc, cmd_argv, &users, c->user_ptr, fd);

            if (res != NULL) {
                if (strcmp(res, "quit") == 0) {
                    return fd;
                }
            } else if (input == NULL) {
                return fd;
            }
            free(input);
        }
    }

    return 0;
}