Why am I getting a segmentation fault
int delete_user(const char *name, User **user_ptr_del) {
    User *curr = *user_ptr_del;
    User *prev = NULL;

    while((strcmp(name, curr->name) != 0) || (curr != NULL)){
        prev = curr;
        curr = curr->next;
    }

    if (curr == NULL){
        return 1;
    }

    if (prev == NULL){
        curr->next = NULL;
    } else{
        prev->next = curr->next;
        curr->next = NULL;
    }
    
    int length = 0;
    for(int i = 0; i < 10; i++){
        if (curr->friends[i] != NULL){
            length = length + 1;
        }
    }

    for(int i = 0; i < length; i++){
        int length2 = 0;
        for (int a = 0; a < 10; a++){
            if(curr->friends[i]->friends[a] != NULL){
                length2 = length2 + 1;
            }
        }
        for(int j = 0; j < length2; j++){
            if(strcmp(name, curr->friends[i]->friends[j]->name) == 0){
                for (int x = j; x < length2 - 1; x++){
                    curr->friends[i]->friends[x] = curr->friends[i]->friends[x + 1];
                }
                curr->friends[i]->friends[length2 - 1] = NULL;
            }
        }
    }

    for(int i = 0; i < 10; i++){
        if (curr->friends[i] != NULL){
            free(curr->friends[i]);
        }
    }

    // Post *curr3 = curr->first_post;
    while(curr->first_post != NULL){
        free(curr->first_post->author);
        free(curr->first_post->contents);
        free(curr->first_post->date);
        curr->first_post = curr->first_post->next;
    }
    curr->first_post->next = NULL;

    free(curr->name);
    free(curr->profile_pic);
    free(curr->friends);
    free(curr->first_post);
    free(curr);
    return 0;
}