title: munmap_chunk(): invalid pointer (error in while condition)
body: <p>i have unknown error in my code after i test my code by printing i know that function that cause the error :</p>
  
  <pre><code>void clearTrainSet(){
  
          struct trainSet * curSet=trnHead;
          struct trainSet * tmp;
  puts("z");
          while(curSet!=NULL){
  puts("0");
                  tmp=curSet;
  puts("1");
                  curSet=curSet-&gt;next;
  puts("2");
                  free(tmp-&gt;input);
  puts("3");
                  free(tmp-&gt;output);
  puts("4");
                  free(tmp);
  puts("x");
          }
          trnHead=NULL;
          if(filename!=NULL){
                  free(filename);
                  filename=NULL;
          }
  puts("c");
  }
  </code></pre>
  
  <p>after testing the program the result is:</p>
  
  <pre><code>./neuromz -new 1 2 3 -name dsd
  Network initialized successfully.
  z
  *** Error in `./neuromz': munmap_chunk(): invalid pointer: 0x00007ffde363d2c0 ***
  Aborted (core dumped)
  </code></pre>
  
  <p>so the error in while's condition</p>