title: Getting runtime load of address error while writing code for merging two sorted linked list
body: <p>Using a dummy node to add the lesser node of list l1 and list l2. At the end returning the location pointing next to the dummy node to get the actual merged sorted list but getting a runtime load of address with insufficient space for an object of type struct ListNode at return dummyNode->next.</p>
  
  <pre><code>struct ListNode* mergeTwoLists(struct ListNode* l1, struct ListNode* l2) {
          if (l1 == NULL &amp;&amp; l2 != NULL) {
                  return l2;
          }
          if (l1 != NULL &amp;&amp; l2 == NULL) {
                  return l1;
          }
          struct ListNode *dummyNode = NULL;
          struct ListNode *head = NULL;
  
          dummyNode = (struct ListNode *)malloc(sizeof(struct ListNode *));
          head = dummyNode;
  
          while (l1 != NULL &amp;&amp; l2 != NULL) {
                  if (l1-&gt;val &lt;= l2-&gt;val) {
                          head-&gt;next = l1;
                          l1 = l1-&gt;next;
                          head = head-&gt;next;
                  }
                  else {
                          head-&gt;next = l2;
                          l2 = l2-&gt;next;
                          head = head-&gt;next;
                  }
          }
          if (l1 != NULL) {
                  head-&gt;next = l1;
          }
          if (l2 != NULL) {
                  head-&gt;next = l2;
          }    
          return dummyNode-&gt;next;
  }
  
  
  </code></pre>