nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] Patch for bug #44950


From: Rishabh Dave
Subject: Re: [Nano-devel] Patch for bug #44950
Date: Sun, 17 Jan 2016 23:34:23 +0530

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?


On Sun, Jan 17, 2016 at 9:21 PM, Benno Schulenberg <address@hidden> wrote:

On Fri, Jan 15, 2016, at 22:47, Mike Frysinger wrote:
> On 16 Jan 2016 00:26, Rishabh Dave wrote:
> > +    char *parentdir = charalloc(lenpath * sizeof(char));
> > +    char *pparentdir = charalloc(lenpath * sizeof(char));
>
> afaict, these pointers are still leaked in all cases

Yes, patch is not ready yet.  This time 'round he concentrated
just on getting the right message out at the right moment.

Benno

--
http://www.fastmail.com - IMAP accessible web-mail



reply via email to

[Prev in Thread] Current Thread [Next in Thread]