What are the bugs in my code that causes errors?
int make_friends(const char *name1, const char *name2, User *head) {
    // find both users
    User *user1 = find_user(name1, head);
    User *user2 = find_user(name2, head);

    // at least one of the users does not exist, return 4
    if (user1 == NULL || user2 == NULL) {
        return 4;
    }

    // same user passed in twice, return 3
    if (strcmp(name1, name2) == 0) {
        return 3;
    }

    int l1 = num_friends(user1); // number of friends in user1's friend list
    int l2 = num_friends(user2); // number of friends in user2's friend list

    // at least one user has MAX_FRIENDS friends, return 2
    if (l1 == 10 || l2 == 10) {
        return 2;
    }

    // users are already friends, return 1
    if (index_in_friends(user1, user2) != -1 && index_in_friends(user2, user1) != -1) {
        return 1;
    }

    (user1->friends)[l1] = user2; // add user2 to user1's friends
    (user2->friends)[l2] = user1; // add user1 to user2's friends

    // successfully made user1 and user2 friends
    return 0;
}

int num_friends(const User *user) {
    // loop through list of friends of user - list of friends stored as all NULL values at the end
    for (int i = 0; i < 10; i++) {
        if ((user->friends)[i] == NULL) { // first NULL element indicates number of friends
            return i;
        }  
    }
    return 10;
}

int index_in_friends(const User *user1, const User *user2) {
    for (int i = 0; i < 10; i++) {
        if ((user1->friends)[i] == user2) {
            return i;
        }
    }
    return -1;
}