Re: Collection of memory leaks for ECPG driver

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Collection of memory leaks for ECPG driver
Date: 2015-06-12 13:01:26
Message-ID: 20150612130126.GA27586@feivel.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 08, 2015 at 10:50:25PM +0900, Michael Paquier wrote:
> And the caller needs to be sure that str actually allocates enough
> space.. That's not directly ECPG's business, still it feels

But there is no way for us to fix this as we want to implement the API as
defined in Informix.

> uncomfortable. I fixed it with the attached.

Thanks, committed.

> The world is full of surprises, and even if free(NULL) is a noop on
> modern platforms, I would rather take it defensively and check for a
> NULL pointer as Postgres supports many platforms. Other code paths
> tend to do already so, per se for example ECPGconnect.

Right, that's because they were developed before free received the safeguard, or the programmer simply didn't know at that point in time. Unless I'm mistaken we have other code that only calls free() without an additional safeguard, so why shuld ecpglib be special? If you don't like it using both approaches, feel free to remove the check in the other case. :)

More seriously, though, does anyone know of any platform where free(NULL) is *not* a noop?

I don't like adding stuff just because of the world being full of surprises.
There may also be other functions not working as advertized. Wouldn't that
then mean we cannot use any function nor provided by ourselves?

> Perhaps I am overdoing it. I would have them for correctness (some
> other code paths do so) but if you think that the impact is minimal
> there then I am fine to not modify descriptor.c.

Sorry, I wasn't referring to descriptor.c but to the whole preproc/ subtree. But as I already said, since we went through the effort we can of course apply it.

Will be in my next push.

Thanks.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at gmail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-06-12 13:22:42 Re: On columnar storage
Previous Message Petr Jelinek 2015-06-12 12:47:22 Re: 9.5 release notes