title: double free or corruption (fasttop)
body: <p>This code reads a null terminated string from a file (file containing null terminated strings &amp; should provide index to wanted string).<br><br></p>
  
  <p>Error:</p>
  
  <pre><code>*** Error in `./main': double free or corruption (fasttop): 0x090a4a80 ***
  Aborted
  </code></pre>
  
  <p>Code:   </p>
  
  <pre><code>char *tmp_realloc=NULL;
  char *sstring=NULL;
  int i=1;
  
  /*Set file pointer to point string*/
  fseek(fh,index,SEEK_SET);
  
  sstring=(char*)malloc(sizeof(char));
     if(sstring == NULL)
          return NULL;
  
  tmp_realloc=sstring;
  
  while( (*(sstring+i-1)=(char)fgetc((FILE*)fh)) != 0x0 ) {
      /*reallocate more memory*/
       tmp_realloc=(char*)realloc((char*)sstring,++i);
  
       /*if not same address copy old to new &amp; set old to point new*/
        if(tmp_realloc != sstring){
            strcpy((char*)tmp_realloc,(char*)sstring);
            free(sstring);
            sstring=tmp_realloc;
        }
  }
  </code></pre>
  
  <p>Could you tell me what pointer is causing this issue (&amp; for what reason) ?</p>