title: C: free(): invalid next size (fast)
body: <p>Hello i've spent the last couple hours looking through this code attemting to find what is causing this memory error. Ive been told repeatedly that it is a situation of freeing something which was never malloced or freeing something twice, but I have gone through and shrunk the code down to make sure that neither of these is possible. The whole project is a linked list, but ive taken out most of the components of the project to make the smallest possible replication of the error. THanks!
  The Code:  </p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include "list.h"
  
  struct lnode{
    int count;
    int line;
    struct lnode *next;
    char *word;
  }; 
  
  struct lnode* newNode (char* word, int line) {
    struct lnode *myNode = malloc(sizeof(struct  lnode*));
  
    myNode-&gt;word = (char*)malloc((strlen(word))*sizeof(char));
    strcpy(myNode-&gt;word,word);
    myNode-&gt;count = 1;
    myNode-&gt;line = line;
    myNode-&gt;next = NULL;
    return myNode;
  }
  void freeNode(struct lnode * myNode){
    //free(myNode-&gt;word);
    //myNode-&gt;word = NULL;
    free(myNode);
    myNode = NULL;
  }
  int main(){
    struct lnode *n = newNode("Test", 2);
    free(n);
    return 0;
  }
  </code></pre>
  
  <p>Gives this error:  </p>
  
  <pre><code>*** glibc detected *** ./listTest: free(): invalid next size (fast): 0x085d008 ***
  </code></pre>