Skip to content

Commit c859294

Browse files
committed
Remove hash_destroy calls in hash_create's failure paths. As noted by
a Coverity warning, these are risky since the hashtable isn't necessarily fully set up yet. They're unnecessary anyway: a deletable hashtable should be in a memory context that will be cleared following elog(ERROR). Per report from Martijn van Oosterhout.
1 parent f058451 commit c859294

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/backend/utils/hash/dynahash.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.70 2006/07/22 23:04:39 tgl Exp $
29+
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.71 2006/08/14 12:39:55 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -392,10 +392,7 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
392392

393393
/* Build the hash directory structure */
394394
if (!init_htab(hashp, nelem))
395-
{
396-
hash_destroy(hashp);
397395
elog(ERROR, "failed to initialize hash table");
398-
}
399396

400397
/*
401398
* For a shared hash table, preallocate the requested number of elements.
@@ -409,12 +406,9 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
409406
nelem < hctl->nelem_alloc)
410407
{
411408
if (!element_alloc(hashp, (int) nelem))
412-
{
413-
hash_destroy(hashp);
414409
ereport(ERROR,
415410
(errcode(ERRCODE_OUT_OF_MEMORY),
416411
errmsg("out of memory")));
417-
}
418412
}
419413

420414
return hashp;

0 commit comments

Comments
 (0)