title: equation double pointer to NULL gives segmentation fault in C
body: <pre><code>#include&lt;stdio.h&gt;
  #include&lt;malloc.h&gt;
  
  typedef struct Node {
   int data;
   struct Node * next;
  } Node;
  
  
  void push(Node **headRef, int i){
  //why does headRef == NULL in below if condition gives segmentation fault?
    if(*headRef == NULL){
      *headRef = malloc(sizeof(Node));
      Node *head = *headRef;
      head-&gt;data = i;
    }
  }
  
  int main(int argc, char ** argv){
    Node *head = NULL;
    push(&amp;head, 2);
    printf("%d\n", head-&gt;data);
  }
  </code></pre>
  
  <p>This code is of linked list where I try to push some data into the list.
  My question is in the comment of push function.</p>