Re: [PATCHES] Re: [HACKERS] Everything leaks; How it mm suppose to work? - Mailing list pgsql-hackers

From Vadim B. Mikheev
Subject Re: [PATCHES] Re: [HACKERS] Everything leaks; How it mm suppose to work?
Date
Msg-id 35278D31.5115AC54@sable.krasnoyarsk.su
Whole thread Raw
Responses Re: [PATCHES] Re: [HACKERS] Everything leaks; How it mm suppose to work?
List pgsql-hackers
Bruce Momjian wrote:
>
> > I seem to recall a discussion a long time ago about using strdup and how
> > it would leak when using the postgres memory contexts, and that the pstrdup
> > code was created to be used instead of strdup to "fix" this.
> >
>
> OK, here is a patch to fix the memory leak problem.  Not sure when this
> was introduced, but who cares.  Probably not Vadim, as I first thought.

(Sure - not me :). Congratulations with finding this!
storage/buffer/bufmgr.c:BufferAlloc():

    strcpy(buf->sb_dbname, GetDatabaseName());

and so we had leak for _every_ new buffer allocation!

But why strdup() was added there? (Hope that nothing is broken now).

Vadim

pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Open 6.3.1 issues
Next
From: "Thomas G. Lockhart"
Date:
Subject: Automatic type conversion