Clarification regarding NULL pointers in context of Binary tree : I have a data structure like:

    struct node
    {
       int count;
       node *left,*right;
       node(int count,node* l,node*r)
       {
          this->count=count;
          this->left=l;
          this->right=r;
       }
       node* update(int l,int r,int v);
    };
    

Now i declare a global variable:

**node* p=new node(0,NULL,NULL);**

So this very statement will cause 'p' to have :

    p->count=0;  
    p->left=NULL;
    p->right=NULL;

    My question is what happens if I write:
    p->left=p->right=p;
    As far as i understood that it will give memory to
    p->left and p->right which were NULL initially.
    So, it would be:
    p->left->count=0, p->left->left=NULL,p->left->right=NULL;
    p->right->count=0, p->right->left=NULL,p->right->right=NULL;

    But i do not think that's what happening because when  i am calling
    update(0,9,0) where l=0, r=9 and v=0, it is working fine if i have
    written this statement: p->left=p->right=p before calling this
    function.
    But it fails to run if i comment this statement (i.e. it tries to access
    NULL pointer values i guess).
    Please clarify this doubt.
    Thank You.

