Skip site navigation (1) Skip section navigation (2)

hash_create(): check return code

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: hash_create(): check return code
Date: 2004-10-22 05:40:55
Message-ID: 1098423655.6602.287.camel@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-patches
hash_create() can return a NULL pointer if an error occurs (principally,
when we're out of memory). Some of the call sites checked for this
condition, but some did not. This patch fixes the remaining call sites
to check the return value, and ereport(ERROR) if it is NULL.

I'm not really sure whether this is the correct fix, but it certainly
seems wrong to be doing the check in some places and not in others.
Another approach would be to elog(ERROR) when an error occurs in
hash_create(), which would be fine except there might be some
circumstances in which hash_create() is invoked but elog(ERROR) is not
setup yet.

Comments?

-Neil

(Patch attached as a unified diff -- apologies for that, but I'm playing
with a new version control tool that most easily emits unified diffs.
http://www.venge.net/monotone/, if you're curious.)

Attachment: hash_create_oom-1.patch
Description: text/x-patch (3.9 KB)

Responses

pgsql-patches by date

Next:From: Neil ConwayDate: 2004-10-22 06:02:31
Subject: code cleanup in dynahash.c
Previous:From: David FetterDate: 2004-10-22 04:29:44
Subject: Re: Example of function returning SETOF RECORD

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group