Why does this give a segmentation fault? 
int delete_user(const char *name, User **user_ptr_del) {
        User *curr_user = *user_ptr_del;
        if (curr_user == NULL){
                return 1; 
        }
        while (curr_user->next != NULL) {
                if (strcmp((curr_user->next)->name, name) == 0){
                        User *temp = curr_user->next; 
                        rm_from_friends(curr_user->next);
                        curr_user->next = temp->next; 
                        free(temp); 
                        return 0;
                }
                curr_user = curr_user->next; 
        }
        if (curr_user->name == name){
                free(curr_user);
                *user_ptr_del = NULL;
                return 0;
        }
        return 1; 
}


/*
 * Remove user from all of its friends. 
 */
void rm_from_friends(User *user){
        User *friend = *user->friends; 
        while (friend != NULL){
                rm_friend(friend, user);
                friend = friend->next;
        }
}


/*
 * Helper for rm_from_friends.
 */
void rm_friend(User *user, User *user_to_rm){
        User *friend = *user->friends;
        if (friend == NULL){
                return; 
        }
        while (friend->next != NULL){
                if (strcmp((friend->next)->name, user_to_rm->name) == 0){
                        User *temp = friend->next;
                        friend->next = temp->next; 
                        free(temp);
                        return; 
                }
                friend = friend->next; 
        }
        if (strcmp(friend->name, user_to_rm->name) == 0){
                user->friends[0] = NULL; 
                free(friend);
        }
}
