title: C : Valgring warns about "Invalid write/read of size 8" & close syscall
body: <p>I'm testing my binary with valgrind, and I get many warnings like this one :</p>
  
  <pre><code>Invalid write of size 8
  ==7414==    at 0x402AAE: list_create_node (simple_list.c:53)
  ==7414==    by 0x40267E: list_add_elem_at_back (simple_list2.c:21)
  ==7414==    by 0x401C8A: parse (is_valid2.c:31)
  ==7414==    by 0x40246C: ko_parse (main.c:53)
  ==7414==    by 0x40255B: ko (main.c:74)
  ==7414==    by 0x4025E1: main (main.c:96)
  ==7414==  Address 0x6fe52d8 is 0 bytes after a block of size 8 alloc'd
  ==7414==    at 0x4C277AB: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==7414==    by 0x402A75: list_create_node (simple_list.c:50)
  ==7414==    by 0x40267E: list_add_elem_at_back (simple_list2.c:21)
  ==7414==    by 0x401C8A: parse (is_valid2.c:31)
  ==7414==    by 0x40246C: ko_parse (main.c:53)
  ==7414==    by 0x40255B: ko (main.c:74)
  ==7414==    by 0x4025E1: main (main.c:96)
  </code></pre>
  
  <p>I saw that there are many posts about that but I can't find where's the problem in my code :</p>
  
  <pre><code>t_node          *list_create_node(char *element)
  {
    t_node        *node;
  
    if ((node = malloc(sizeof(t_node *))) == NULL)
      return (NULL);
    if ((node-&gt;value = strdup(element)))
      node-&gt;next = NULL; //// line 53 from simple_list.c
    return (node);
  }
  </code></pre>
  
  <p>Am I doing something wrong?</p>
  
  <p>Valgrind also warns about reading...And that :</p>
  
  <pre><code>==7415== Warning: invalid file descriptor 1024 in syscall close()
  </code></pre>
  
  <p>I have a close() smewhere in my code, but even when I comment it, the message keeps being displayed. Why is that?</p>