rem: free ((char *) first);
add: free (first);
context: pipe_lines (const char *pretty_filename, int fd, long int n_lines){  struct linebuffer  {    int nbytes, nlines;    char buffer[BUFSIZ];    struct linebuffer *next;  };  typedef struct linebuffer LBUFFER;  LBUFFER *first, *last, *tmp;  int i;			/* Index into buffers.  */  int total_lines = 0;		/* Total number of newlines in all buffers.  */  int errors = 0;  int nbytes;			/* Size of most recent read */  first = last = (LBUFFER *) xmalloc (sizeof (LBUFFER));  first->nbytes = first->nlines = 0;  first->next = NULL;  tmp = (LBUFFER *) xmalloc (sizeof (LBUFFER));  /* Input is always read into a fresh buffer.  */  while ((nbytes = tmp->nbytes = safe_read (fd, tmp->buffer, BUFSIZ)) > 0)    {      tmp->nlines = 0;      tmp->next = NULL;      /* Count the number of newlines just read.  */      for (i = 0; i < tmp->nbytes; i++)	if (tmp->buffer[i] == '\n')	  ++tmp->nlines;      total_lines += tmp->nlines;      /* If there is enough room in the last buffer read, just append the new         one to it.  This is because when reading from a pipe, `nbytes' can         often be very small.  */      if (tmp->nbytes + last->nbytes < BUFSIZ)	{	  memcpy (&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes);	  last->nbytes += tmp->nbytes;	  last->nlines += tmp->nlines;	}      else	{	  /* If there's not enough room, link the new buffer onto the end of	     the list, then either free up the oldest buffer for the next	     read if that would leave enough lines, or else malloc a new one.	     Some compaction mechanism is possible but probably not	     worthwhile.  */	  last = last->next = tmp;	  if (total_lines - first->nlines > n_lines)	    {	      tmp = first;	      total_lines -= first->nlines;	      first = first->next;	    }	  else	    tmp = (LBUFFER *) xmalloc (sizeof (LBUFFER));	}    }  free ((char *) tmp);  if (nbytes < 0)    {      error (0, errno, "%s", pretty_filename);      errors = 1;      goto free_lbuffers;    }  /* If the file is empty, then bail out.  */  if (last->nbytes == 0)    goto free_lbuffers;  /* This prevents a core dump when the pipe contains no newlines.  */  if (n_lines == 0)    goto free_lbuffers;  /* Count the incomplete line on files that don't end with a newline.  */  if (last->buffer[last->nbytes - 1] != '\n')    {      ++last->nlines;      ++total_lines;    }  /* Run through the list, printing lines.  First, skip over unneeded     buffers.  */  for (tmp = first; total_lines - tmp->nlines > n_lines; tmp = tmp->next)    total_lines -= tmp->nlines;  /* Find the correct beginning, then print the rest of the file.  */  if (total_lines > n_lines)    {      const char *cp;      /* Skip `total_lines' - `n_lines' newlines.  We made sure that         `total_lines' - `n_lines' <= `tmp->nlines'.  */      cp = tmp->buffer;      for (i = total_lines - n_lines; i; --i)	while (*cp++ != '\n')	  /* Do nothing.  */ ;      i = cp - tmp->buffer;    }  else    i = 0;  xwrite (STDOUT_FILENO, &tmp->buffer[i], tmp->nbytes - i);  for (tmp = tmp->next; tmp; tmp = tmp->next)    xwrite (STDOUT_FILENO, tmp->buffer, tmp->nbytes);free_lbuffers:  while (first)    {      tmp = first->next;      free ((char *) first);      first = tmp;    }  return errors;}