how to fix the memory leak by allocating memory for a new user and copying the data from the local user to the new user.

int make_friends(const char *name1, const char *name2, User *head) {  
    // find the users  
    User *user1 = find_user(name1, head);  
    User *user2 = find_user(name2, head);  
    //check if at least one user doesn't exist  
    if (!user1 || !user2){  
        return 4;  
    }  
  
    // check if the users are equal  
    else if (user1 == user2){  
        return 3;  
    }  
  
    // initialize the number of friends each user has  
    int user1_friends = 0;  
    int user2_friends = 0;  
  
    // loop counts the number of friends each user has to see if they  
    // exceed the maximum number of friends  
    for (int i = 0; i < MAX_FRIENDS; i++) {  
        if (user1->friends[i] != NULL) {  
            user1_friends++;  
        }  
        if (user2->friends[i] != NULL) {  
            user2_friends++;  
        }  
    }   
    if (user1_friends == MAX_FRIENDS || user2_friends == MAX_FRIENDS) {  
        return 2;  
    }  
  
    // checks if the users are already friends  
    for (int j = 0; j < MAX_FRIENDS; j++) {  
        if (user1->friends[j] == user2) {  
            return 1;  
        }  
    }  
  
    // otherwise, adds the users to each of their firends  
    for (int i = 0; i < MAX_FRIENDS; i++) {  
        if (user1->friends[i] == NULL) {  
            user1->friends[i] = user2;  
            break;  
        }  
    }  
    for (int i = 0; i < MAX_FRIENDS; i++) {  
        if (user2->friends[i] == NULL) {  
            user2->friends[i] = user1;  
            break;  
        }  
    }  
    return 0;  
}

User *find_user(const char *name, const User *head) {  
    // initialize the head of the linked list  
    const User *curr = head;  
  
    while (curr != NULL) {  
        // if match is found, return the user  
        if (strcmp(curr->name, name) == 0){  
            return (User *)curr;  
        }  
        curr = curr->next;  
    }  
    // end of the list was reached without finding user  
    return NULL;  
}  