title: Using realloc to concat strings
body: <p>I'm trying to concat two strings, supposing the "dest" string hasn't enough space to add another one, so I'm using dynamic arrays to solve it.</p>
  
  <p>The problem is a <strong>mremap_chunk</strong> error when trying to compile the code.</p>
  
  <p>I don't know what I'm missing since the realloc call has all the right params place in.</p>
  
  <hr>
  
  <p>Error:    </p>
  
  <pre><code>malloc.c:2869: mremap_chunk: Assertion `((size + offset) &amp; (GLRO (dl_pagesize) - 1)) == 0' failed. 
  Aborted (core dumped)
  </code></pre>
  
  <hr>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  char *strcatt(char *s1, char *s2)
  {
      int a = strlen(s1);
      int b = strlen(s2);
      int i, size_ab = a+b;
  
      s1 = (char *) realloc (s1, size_ab*sizeof(char));
  
      for(i=0; i&lt;b; i++) {
          s1[i+a]=s2[i];
      }
  
      s1[size_ab]='\0';
  
      return s1;
  }
  
  
  int main()
  {
      char s1[]="12345";
      char s2[]="qwerty";
  
      strcatt(s1,s2);
      printf("%s\n", s1);
  
      return 0;
  }
  </code></pre>