for this code I am receiving a segmentation error, how can i fix
void cleanup(Post **pst) {
    free((*pst)->date);
    free((*pst)->contents);
    free((*pst));
    *pst = NULL;
}

int delete_user(const char *name, User **user_ptr_del) {

    struct user *temp = *user_ptr_del, *prev;
    if (find_user(name, temp) == NULL) {
        return 1;
    }

    if (temp != NULL && strcmp(temp->name, name) == 0) {
        *user_ptr_del = temp->next; // Changed head
        free(temp); // free old head
        return 0;
    }

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

    Post *post = temp->first_post;
    cleanup(&post);
    // If key was not present in linked list
    if (temp == NULL){
        return 1;
    }
    remove_friends(name, user_ptr_del);

    prev->next = temp->next;
    
    free(temp); // Free memory
    return 0;
}