title: runtime error: null pointer passed as argument 1, which is declared to never be null
body: <p>I wrote a program that creates Linkedlists with two values.
  It worked when I just had int values in it but now that I added char* this error messages shows
  runtime error: null pointer passed as argument 1, which is declared to never be null</p>
  
  <p>As mentioned before this worked fine until I added char* to the constructor and the struct. Not sure where it goes wrong as the error seems to come from different lines in the code everytime I run it... So what do i need to change ?</p>
  
  <pre><code>   #include &lt;stdio.h&gt;
     #include &lt;cs50.h&gt;
     #include &lt;string.h&gt;
  
  typedef struct node  {
          int val;
          char* name;
          struct node *next;
  } node_t;
  
  void addFirst(int value, char* word, node_t** nd) {
          //initialize new node, allocate space, set value
      node_t * tmp;
      tmp = malloc(sizeof(node_t));
      tmp-&gt;val = value;
      strcpy(tmp-&gt;name, word);
      //let the new nodes next pointer point to the old head
      tmp-&gt;next = *nd;
      //Make tmp the head node
      *nd = tmp;
  
  
  
  }
  
  
  int findItem(int value,char* word, node_t *nd) {
      if(nd-&gt;val == value)
      return 0;
      while(nd-&gt;next != NULL) {
      if(nd-&gt;val == value &amp;&amp; strcmp(word, nd-&gt;name) == 0)
      return 0;
  
      if(nd-&gt;next != NULL)
      nd = nd-&gt;next;
      }
      return -1;
  
  }
  
  
  int main (void) {
  
   node_t *head = malloc(sizeof(node_t));
   head-&gt;val = 0;
    strcpy(head-&gt;name, "");
      head-&gt;next = NULL;
      addFirst(15, "word", &amp;head);
      addFirst(14,"word2", &amp;head);
  
  
      printf("%i \n", findItem(15, "word", head));
  
  }
  </code></pre>