title: malloc(): smallbin double linked list corrupted
body: <p>This code generates an error at runtime in the else:</p>
  
  <blockquote>
    <p>non exists
    *** Error in `./a.out': malloc(): smallbin double linked list corrupted: 0x09faed58 ***
    Aborted (core dumped)</p>
  </blockquote>
  
  <pre><code>bool fileExists(char *file) {
      if (access(file, F_OK) != -1) {
          return true;
      } else {
          return false;
      }
  }
  
  void CopyPaste() {
     char *fileName = basename(path);
     char *c = strcat(dest, "/");
     char *newPath = strcat(c, fileName);
  
     if (fileExists(newPath)) {
         printf("exists\n");
     } else {
         printf("non exists\n");
     }
  }
  </code></pre>
  
  <p>If I change the concatenation code like that:</p>
  
  <pre><code>char *newPath = strcat(strcat(dest,"/"),fileName);
  </code></pre>
  
  <p>it generates this different error:</p>
  
  <blockquote>
    <p>Error in `./a.out': corrupted double-linked list</p>
  </blockquote>
  
  <p>What might the problem be?</p>