title: *glibc detected double free or corruption() * message!
body: <p>The following deleteNode function when I run the program gets these:
  <strong>* glibc detected <em></strong> free(): invalid next size (normal): 0x000000000103dd90 *</em>*</p>
  
  <p>Even i make the ' free(here); ' a comment,i get the above message.
  I dont think that the other 'free' calls provokes a problem like that. But I cant see why this would be wrong. :/</p>
  
  <pre><code>struct List *deleteNode(int Code,int i,char* Number)
      {
          struct List *here;
          here=Head;
  
          for (here; here!=Tail; here=here-&gt;next)
          {       
              if ( (here-&gt;number==Number) &amp;&amp; (here-&gt;code==Code) )//found node on the List
              {
                  if (here-&gt;previous==Head)        //delete from beginning
                  {           
                      Head=here-&gt;next;
                      here-&gt;next-&gt;previous=Head;
                  }
                  else if (here-&gt;next==Tail) //delete from the end
                  {
                      here-&gt;previous-&gt;next=Tail;
                      Tail=here-&gt;previous;
                  }
                  else  //delete from the middle of the list
                  {   
                      here-&gt;previous-&gt;next=here-&gt;next;
                      here-&gt;next-&gt;previous=here-&gt;previous;
                  }
                  break;
              }
          }
  
          free (here);
  
      }
  </code></pre>
  
  <p>EDIT:
  if i used and understand valgring well then the problem is on my main function.
  i have also there some 'free' but i changed deleteNode before this message so i thought that the problem was on the deleteNode function.</p>
  
  <p>Now,there is no free() invalid next size.... but unfortunately this:
  glibc detected <strong>* : double free or corruption (out): 0x00007fff1aae9ae0 *</strong>
  :(</p>
  
  <p>A part of the main:</p>
  
  <pre><code>FILE *File;
      if ( ( File=fopen("File.txt","r")) !=NULL )
      {                               
          int li = 0;    
          char *lin = (char *) malloc(MAX_LINE * sizeof(char));
  
  
          while(fgets(lin, MAX_LINE, eventFile) != NULL)
          {
              token = linetok(lin, " ");
  
              if(token != NULL)
              {
  
                  int i,code,nodeID;
              char *number;
              char *event;
  
                  for(i = 0; token[i] != NULL; i += 1)
                  {
              code=atoi(token[0]);
              strcpy(event,token[1]);
              nodeID=atoi(token[2]);
              strcpy(number,token[3]) ;
  
              int i;
              if (!strcmp(event,"add"))
              {       
                  add_to_List(code,i,number);
              }
              else if(!strcmp(event,"delete"))
              {       
                               deleteNode(eventNo,i,number);
                      }
              free(event);
              free(phoneNumber);  
          }
                  free(token);
              }
              else 
              {
                  printf("Error reading line %s\n", lin);
                  exit(1);   
              }
          }
      } 
      else 
      {
          printf("Error opening file with the events.\nEXIT!");
          exit(0);
      }
  </code></pre>
  
  <p>debugging it...</p>
  
  <p>multiple definition of <code>main'
  pro:(.text+0xce0): first defined here
  /usr/lib/gcc/x86_64-linux-gnu/4.4.1/crtend.o:(.dtors+0x0): multiple definition of</code><strong>DTOR_END</strong>'
  pro:(.dtors+0x8): first defined here
  /usr/bin/ld: warning: Cannot create .eh_frame_hdr section, --eh-frame-hdr ignored.
  /usr/bin/ld: error in pro1(.eh_frame); no .eh_frame_hdr table will be created.
  collect2: ld returned 1 exit status</p>