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:
parent
381cb046ed
commit
a323ede280
@ -4,7 +4,7 @@
|
|||||||
* darcy@druid.net
|
* darcy@druid.net
|
||||||
* http://www.druid.net/darcy/
|
* http://www.druid.net/darcy/
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.14 2005/10/15 02:49:04 momjian Exp $
|
* $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.15 2006/03/19 22:22:55 neilc Exp $
|
||||||
* best viewed with tabs set to 4
|
* best viewed with tabs set to 4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -108,11 +108,9 @@ chkpass_out(PG_FUNCTION_ARGS)
|
|||||||
chkpass *password = (chkpass *) PG_GETARG_POINTER(0);
|
chkpass *password = (chkpass *) PG_GETARG_POINTER(0);
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
if ((result = (char *) palloc(16)) != NULL)
|
result = (char *) palloc(16);
|
||||||
{
|
|
||||||
result[0] = ':';
|
result[0] = ':';
|
||||||
strcpy(result + 1, password->password);
|
strcpy(result + 1, password->password);
|
||||||
}
|
|
||||||
|
|
||||||
PG_RETURN_CSTRING(result);
|
PG_RETURN_CSTRING(result);
|
||||||
}
|
}
|
||||||
@ -129,11 +127,9 @@ chkpass_rout(PG_FUNCTION_ARGS)
|
|||||||
chkpass *password = (chkpass *) PG_GETARG_POINTER(0);
|
chkpass *password = (chkpass *) PG_GETARG_POINTER(0);
|
||||||
text *result;
|
text *result;
|
||||||
|
|
||||||
if ((result = (text *) palloc(VARHDRSZ + 16)) != NULL)
|
result = (text *) palloc(VARHDRSZ + 16);
|
||||||
{
|
|
||||||
result->vl_len = VARHDRSZ + strlen(password->password);
|
result->vl_len = VARHDRSZ + strlen(password->password);
|
||||||
memcpy(result->vl_dat, password->password, strlen(password->password));
|
memcpy(result->vl_dat, password->password, strlen(password->password));
|
||||||
}
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
PG_RETURN_TEXT_P(result);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Joe Conway <mail@joeconway.com>
|
* Joe Conway <mail@joeconway.com>
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/fuzzystrmatch/fuzzystrmatch.c,v 1.19 2006/03/11 04:38:29 momjian Exp $
|
* $PostgreSQL: pgsql/contrib/fuzzystrmatch/fuzzystrmatch.c,v 1.20 2006/03/19 22:22:56 neilc Exp $
|
||||||
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
|
||||||
* ALL RIGHTS RESERVED;
|
* ALL RIGHTS RESERVED;
|
||||||
*
|
*
|
||||||
@ -347,14 +347,10 @@ _metaphone(
|
|||||||
if (max_phonemes == 0)
|
if (max_phonemes == 0)
|
||||||
{ /* Assume largest possible */
|
{ /* Assume largest possible */
|
||||||
*phoned_word = palloc(sizeof(char) * strlen(word) +1);
|
*phoned_word = palloc(sizeof(char) * strlen(word) +1);
|
||||||
if (!*phoned_word)
|
|
||||||
return META_ERROR;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*phoned_word = palloc(sizeof(char) * max_phonemes + 1);
|
*phoned_word = palloc(sizeof(char) * max_phonemes + 1);
|
||||||
if (!*phoned_word)
|
|
||||||
return META_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-- The first phoneme has to be processed specially. --*/
|
/*-- The first phoneme has to be processed specially. --*/
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* workings can be found in the book "Software Solutions in C" by
|
* workings can be found in the book "Software Solutions in C" by
|
||||||
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
|
* 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"
|
#include "postgres.h"
|
||||||
@ -291,10 +291,7 @@ cash_out(PG_FUNCTION_ARGS)
|
|||||||
/* see if we need to signify negative amount */
|
/* see if we need to signify negative amount */
|
||||||
if (minus)
|
if (minus)
|
||||||
{
|
{
|
||||||
if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol))))
|
result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol));
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
|
||||||
errmsg("out of memory")));
|
|
||||||
|
|
||||||
/* Position code of 0 means use parens */
|
/* Position code of 0 means use parens */
|
||||||
if (convention == 0)
|
if (convention == 0)
|
||||||
@ -306,11 +303,7 @@ cash_out(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count)))
|
result = palloc(CASH_BUFSZ + 2 - count);
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
|
||||||
errmsg("out of memory")));
|
|
||||||
|
|
||||||
strcpy(result, buf + count);
|
strcpy(result, buf + count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +151,6 @@ spi_spi_prepare(query, ...)
|
|||||||
if (items < 1)
|
if (items < 1)
|
||||||
Perl_croak(aTHX_ "Usage: spi_prepare(query, ...)");
|
Perl_croak(aTHX_ "Usage: spi_prepare(query, ...)");
|
||||||
argv = ( SV**) palloc(( items - 1) * sizeof(SV*));
|
argv = ( SV**) palloc(( items - 1) * sizeof(SV*));
|
||||||
if ( argv == NULL)
|
|
||||||
Perl_croak(aTHX_ "spi_prepare: not enough memory");
|
|
||||||
for ( i = 1; i < items; i++)
|
for ( i = 1; i < items; i++)
|
||||||
argv[i - 1] = ST(i);
|
argv[i - 1] = ST(i);
|
||||||
RETVAL = plperl_spi_prepare(query, items - 1, argv);
|
RETVAL = plperl_spi_prepare(query, items - 1, argv);
|
||||||
@ -179,8 +177,6 @@ spi_spi_exec_prepared(query, ...)
|
|||||||
}
|
}
|
||||||
argc = items - offset;
|
argc = items - offset;
|
||||||
argv = ( SV**) palloc( argc * sizeof(SV*));
|
argv = ( SV**) palloc( argc * sizeof(SV*));
|
||||||
if ( argv == NULL)
|
|
||||||
Perl_croak(aTHX_ "spi_exec_prepared: not enough memory");
|
|
||||||
for ( i = 0; offset < items; offset++, i++)
|
for ( i = 0; offset < items; offset++, i++)
|
||||||
argv[i] = ST(offset);
|
argv[i] = ST(offset);
|
||||||
ret_hash = plperl_spi_exec_prepared(query, attr, argc, argv);
|
ret_hash = plperl_spi_exec_prepared(query, attr, argc, argv);
|
||||||
@ -199,8 +195,6 @@ spi_spi_query_prepared(query, ...)
|
|||||||
Perl_croak(aTHX_ "Usage: spi_query_prepared(query, "
|
Perl_croak(aTHX_ "Usage: spi_query_prepared(query, "
|
||||||
"[\\@bind_values])");
|
"[\\@bind_values])");
|
||||||
argv = ( SV**) palloc(( items - 1) * sizeof(SV*));
|
argv = ( SV**) palloc(( items - 1) * sizeof(SV*));
|
||||||
if ( argv == NULL)
|
|
||||||
Perl_croak(aTHX_ "spi_query_prepared: not enough memory");
|
|
||||||
for ( i = 1; i < items; i++)
|
for ( i = 1; i < items; i++)
|
||||||
argv[i - 1] = ST(i);
|
argv[i - 1] = ST(i);
|
||||||
RETVAL = plperl_spi_query_prepared(query, items - 1, argv);
|
RETVAL = plperl_spi_query_prepared(query, items - 1, argv);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* plperl.c - perl as a procedural language for PostgreSQL
|
* plperl.c - perl as a procedural language for PostgreSQL
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.106 2006/03/14 22:48:23 tgl Exp $
|
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.107 2006/03/19 22:22:56 neilc Exp $
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
@ -2122,8 +2122,6 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
|
|||||||
{
|
{
|
||||||
nulls = (char *)palloc( argc);
|
nulls = (char *)palloc( argc);
|
||||||
argvalues = (Datum *) palloc(argc * sizeof(Datum));
|
argvalues = (Datum *) palloc(argc * sizeof(Datum));
|
||||||
if ( nulls == NULL || argvalues == NULL)
|
|
||||||
elog(ERROR, "spi_exec_prepared: not enough memory");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2253,8 +2251,6 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
|
|||||||
{
|
{
|
||||||
nulls = (char *)palloc( argc);
|
nulls = (char *)palloc( argc);
|
||||||
argvalues = (Datum *) palloc(argc * sizeof(Datum));
|
argvalues = (Datum *) palloc(argc * sizeof(Datum));
|
||||||
if ( nulls == NULL || argvalues == NULL)
|
|
||||||
elog(ERROR, "spi_query_prepared: not enough memory");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user