int create_user(const char *name, User **user_ptr_add) {
 /*Check whether the user name already exists in the list
 */
    User *curr1 = *user_ptr_add;
    User curr = *curr1;
    int res = 0;
    while (curr.next){
        if (strcmp(curr.name, name) == 0){
            res = 1;
        }
        curr = *curr.next;
    }
    if (res == 1){
        return res;
    }


/*Check whether the given name cannot fit in the 'name' array
 */
    if (strlen(name) > MAX_NAME - 1){
        return 2;
    }

/*Create the user with name
 */
    User *u1ptr = malloc(sizeof(User));
    User u1 = *u1ptr;
    strcpy(u1.name,name);
    for (int i =0; i <10; i++){
        u1.friends[i] = NULL;
    }
    u1.next = NULL;
    u1.first_post = NULL;
    strcpy(u1.profile_pic,"");
    curr.next = u1ptr;
    return 0;
}
how to solve the segmentation fault.