why is this giving me a segmentation fault
#define MAX_NAME 32     // Max username and profile_pic filename lengths
#define MAX_FRIENDS 10  // Max number of friends a user can have

typedef struct user {
    char name[MAX_NAME];
    char profile_pic[MAX_NAME];  // This is a *filename*, not the file contents.
    struct post *first_post;
    struct user *friends[MAX_FRIENDS];
    struct user *next;
} User;

/*
 * Create a new user with the given name.  Insert it at the tail of the list
 * of users whose head is pointed to by *user_ptr_add.
 *
 * Return:
 *   - 0 if successful
 *   - 1 if a user by this name already exists in this list
 *   - 2 if the given name cannot fit in the 'name' array
 *       (don't forget about the null terminator)
 */
int create_user(const char *name, User **user_ptr_add) {
    // Checks if the name fits into the array.
    if (strlen(name) >= MAX_NAME) {
        return 2;
    } else {
        User *curr = *user_ptr_add;
        User *next = curr -> next;

        // While loop to check if the name is already in the list.
        while (next != NULL) {
            if (strcmp(name, next->name) != 0) {
                curr = curr -> next;
                next = curr -> next;
            } else {
                return 1;
            }
        }

        // Creates the new user and adds it to the list.
        User *new_user = malloc(sizeof(User));
        strcpy(new_user -> name, name);
        curr->next = new_user;
        new_user->next = NULL;

        return 0;
    }
}
