unchecked malloc

From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: unchecked malloc
Date: 2005-09-27 07:29:15
Message-ID: dhahqs$90r$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

There are several places in both backend and tools that forget to check the
return value of malloc(). For example(8.0.1),

backend/port/dynloader/beos.c/pg_dlopen()
backend/bootstrap/bootstrap.c/AddStr()
port/strdup.c/strdup()
bin/pg_dump/common.c/findParentsByOid()
...

I am thinking we should fix them. Basically we have two ways, one is to
define a pg_malloc() as psql already did, the other is to fix these places
one by one. I prefer the first method, since it hides the return value check
details in the function and less error proning. To report the "out of
memory" error, we should differenciate if ErrorContext is already set up.

Comments?

Regards,
Qingqing

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2005-09-27 07:38:28 Re: Making pgxs builds work with a relocated installation
Previous Message Steve Atkins 2005-09-27 06:11:23 Re: State of support for back PG branches