why does this code have segmentation fault?
int make_post(const User *author, User *target, char *contents) {

    if (author == NULL || target == NULL){
    return 2; }
    int are_friends = 0;
    for (int i = 0; i < MAX_FRIENDS; i++){
    if ((author->friends)[i] == target){
     are_friends = 1;
    }
    
    }
    
    if (are_friends == 0){
    
    return 1;
    }
    
    struct post *temp1=malloc(sizeof(struct post));
    
    temp1 = author->first_post;
    struct post *temp2=malloc(sizeof(struct post));
    temp2 = target->first_post;
    strcpy((char *)author->name, author->first_post->author);
    author->first_post->contents = contents;
    
    time(author-> first_post->date);
    time(target-> first_post->date); 
    strcpy((char*)author->name, author->first_post->author);
    target->first_post->contents = contents;
    author->first_post->next = temp1;
    target->first_post->next = temp2;
    



    return 0; 
}

