Re: [BUGS] pg_ctl infinite loop and memory leak

2009-09-17 Thread Bruce Momjian
Jeff Davis wrote: > To reproduce: > > 1. initdb -D data > 2. cat /dev/null > data/postgresql.conf > 3. pg_ctl -w -D data start > > I attached a quick patch that seems to do the trick. It appears that > fgets() will always return non-NULL if the size passed in is 1 (i.e. > maxlength in the caller

Re: [BUGS] pg_ctl infinite loop and memory leak

2009-09-01 Thread Tom Lane
Jeff Davis writes: > On Tue, 2009-09-01 at 22:01 -0400, Tom Lane wrote: >> Where's the memory leak? > The xstrdup() on the zero-length string. Oh, I see. But actually, it's also clobbering memory like crazy (since we'll run off the result[] array in no time). Surprising it doesn't crash from t

Re: [BUGS] pg_ctl infinite loop and memory leak

2009-09-01 Thread Jeff Davis
On Tue, 2009-09-01 at 22:01 -0400, Tom Lane wrote: > Huh, interesting corner case. I'd be inclined to fix by initializing > maxlength to 1 though. > > Where's the memory leak? The xstrdup() on the zero-length string. Regards, Jeff Davis -- Sent via pgsql-bugs mailing list (pgsql-bugs

Re: [BUGS] pg_ctl infinite loop and memory leak

2009-09-01 Thread Tom Lane
Jeff Davis writes: > I attached a quick patch that seems to do the trick. It appears that > fgets() will always return non-NULL if the size passed in is 1 (i.e. > maxlength in the caller is 0). Huh, interesting corner case. I'd be inclined to fix by initializing maxlength to 1 though. Where's t