Why do I get an invalid pointer
int delete_user(const char *name, User **user_ptr_del) {
    User *curr = *user_ptr_del;
    User *prev = NULL;

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

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

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

    for(int i = 0; (i < length) && (curr->friends[i] != NULL); i++){
        int length2 = 0;
        for (int a = 0; (a < 10) && (curr->friends[i]->friends[a] != NULL); a++){
            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;
            }
        }
    }

     printf("good");

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

    printf("good");

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