First of all, sorry for late reply
I am unable to fix memory leak. It's still there. Rest of the patch is ready, I suppose. I am posting code in mail itself for the sake of convenience but I have also attached the patch.
/* Determine whether the components in a path are valid directories. If
* some component is faulty, display faulty path and turn faulty_path TRUE. */
void fault_in_path(const char *filename)
{
char *parentdir = strdup(filename);
struct stat parentinfo;
parentdir = dirname(parentdir);
if (stat(parentdir, &parentinfo) != -1 && S_ISDIR(parentinfo.st_mode)) {
faulty_path = FALSE;
// free(parentdir);
} else {
statusbar(_("Directory '%s' doesn't exists"), parentdir);
faulty_path = TRUE;
free(parentdir);
}
}
Memory leak is pointed out at line 5 (first line in function) irrespective of whatever I use (mallocstrcpy() or a combination malloc() and strcpy()).
If 'free(parentdir)' inside if-block is not under a comment, nano crashes with shell reporting 'free(): invalid pointer: '.
If do 'src/nano foo/bar' some more code would leak memory that I haven't touched. The problem is same as one I stumbled upon using valgrind in very previous mail.
Can anyone help by directing me here? A reference would also be enough. I will take care of rest - learning it and mending it; if there is no hurry to get patch ready for next release.
Other than memory leak, is rest of the patch fine enough to call it final?