rem: char *dir = dir_name (file); int rv = chdir (dir); free (dir);
add: char *xdir = dir_name (file); char *dir; ASSIGN_STRDUPA (dir, xdir); free (xdir);
context: find_mount_point (const char *file, const struct stat *file_stat){  struct saved_cwd cwd;  struct stat last_stat;  char *mp = 0;			/* The malloced mount point path.  */  if (save_cwd (&cwd))    return NULL;  if (S_ISDIR (file_stat->st_mode))    /* FILE is a directory, so just chdir there directly.  */    {      last_stat = *file_stat;      if (chdir (file) < 0)	return NULL;    }  else    /* FILE is some other kind of file, we need to use its directory.  */    {      char *dir = dir_name (file);      int rv = chdir (dir);      free (dir);      if (rv < 0)	return NULL;      if (stat (".", &last_stat) < 0)	goto done;    }  /* Now walk up FILE's parents until we find another filesystem or /,     chdiring as we go.  LAST_STAT holds stat information for the last place     we visited.  */  for (;;)    {      struct stat st;      if (stat ("..", &st) < 0)	goto done;      if (st.st_dev != last_stat.st_dev || st.st_ino == last_stat.st_ino)	/* cwd is the mount point.  */	break;      if (chdir ("..") < 0)	goto done;      last_stat = st;    }  /* Finally reached a mount point, see what it's called.  */  mp = xgetcwd ();done:  /* Restore the original cwd.  */  {    int save_errno = errno;    if (restore_cwd (&cwd))      error (EXIT_FAILURE, errno,	     _("failed to return to initial working directory"));    free_cwd (&cwd);    errno = save_errno;  }  return mp;}