title: Freeing memory after calling strtok() causes an error
body: <p>Could you please help me? My code does tokenizing, so I created code like this:</p>
  
  <ol>
  <li>I allocate some memory,</li>
  <li>I <code>strcpy(malloced_memory, argv)</code></li>
  <li>I execute <code>strtok(mallocted_memory, ".")</code></li>
  <li><p>Try <code>free(mallocted_memory)</code>.</p>
  
  <pre><code>filename = malloc(strlen(argv));
  
  strcpy(filename, argv);
  strk_ptr = malloc(sizeof(filename));
  strk_ptr = strtok(filename,".");//
  i++;
  sprintf(in-&gt;file_name,"%s",strk_ptr);
  
  while(strk_ptr = strtok(NULL,"."))//
  {
      i++;
      sprintf(in-&gt;file_name,"%s.%s",in-&gt;file_name,strk_ptr);
      sprintf(in-&gt;file_ext ,"%s",strk_ptr);
  }
  free(strk_ptr);
  free(filename);
  </code></pre></li>
  </ol>
  
  <p>That code has the problem that I can't <code>free(filename)</code>. If I try <code>free(filename)</code>, then program get <code>SIGTRAP</code>. But program is working.</p>
  
  <p>I want fix that problem. What should I do?</p>