1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-23 14:01:44 +03:00

Fix a few places that were checking for the return value of palloc() to be

non-NULL: palloc() ereports on OOM, so we can safely assume it returns a
valid pointer.
This commit is contained in:
Neil Conway
2006-03-19 22:22:56 +00:00
parent 381cb046ed
commit a323ede280
5 changed files with 12 additions and 37 deletions

View File

@ -9,7 +9,7 @@
* workings can be found in the book "Software Solutions in C" by
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
*
* $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.66 2005/10/15 02:49:28 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.67 2006/03/19 22:22:56 neilc Exp $
*/
#include "postgres.h"
@ -291,10 +291,7 @@ cash_out(PG_FUNCTION_ARGS)
/* see if we need to signify negative amount */
if (minus)
{
if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol))))
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol));
/* Position code of 0 means use parens */
if (convention == 0)
@ -306,11 +303,7 @@ cash_out(PG_FUNCTION_ARGS)
}
else
{
if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count)))
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
result = palloc(CASH_BUFSZ + 2 - count);
strcpy(result, buf + count);
}