title: strdup invalid read of size 4 when string literal is ending with newline \n
body: <p>I am getting an invalid read error when the src string ends with <code>\n</code>, the error disappear when i remove <code>\n</code>:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main (void)
  {
      char *txt = strdup ("this is a not socket terminated message\n");
      printf ("%d: %s\n", strlen (txt), txt);
      free (txt);
      return 0;
  }
  </code></pre>
  
  <p>valgrind output:</p>
  
  <pre><code>==18929== HEAP SUMMARY:
  ==18929==     in use at exit: 0 bytes in 0 blocks
  ==18929==   total heap usage: 2 allocs, 2 frees, 84 bytes allocated
  ==18929== 
  ==18929== All heap blocks were freed -- no leaks are possible
  ==18929== 
  ==18929== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
  ==18929== 
  ==18929== 1 errors in context 1 of 1:
  ==18929== Invalid read of size 4
  ==18929==    at 0x804847E: main (in /tmp/test)
  ==18929==  Address 0x4204050 is 40 bytes inside a block of size 41 alloc'd
  ==18929==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
  ==18929==    by 0x8048415: main (in /tmp/test)
  ==18929== 
  ==18929== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
  </code></pre>
  
  <p>How to fix this without sacrificing the new line character?</p>