My code creates two new nodes in a tree structure below a parent node passed to the function via pointer. Assigning the parent node as the parent of the new nodes works correctly, but the program throws a seg fault when it attempts to assign the new nodes as the left and right children of the parent
//Create new nodes
node* new1 = (node*)malloc(sizeof(node));
new1->parent = par;
node* new2 = (node*)malloc(sizeof(node));
new2->parent = par;
par->left = new1;
par->right = new2;
Here is the struct for reference
typedef struct nd {
int data;
struct nd* parent;
struct nd* left;
struct nd* right;
}node;