mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Return error if allocation of new element was not possible.
Found by Coverity.
This commit is contained in:
parent
579dae5bc0
commit
9c68834bfc
@ -430,14 +430,18 @@ PGTYPESnumeric_to_asc(numeric *num, int dscale)
|
|||||||
numeric *numcopy = PGTYPESnumeric_new();
|
numeric *numcopy = PGTYPESnumeric_new();
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if (dscale < 0)
|
if (numcopy == NULL)
|
||||||
dscale = num->dscale;
|
return NULL;
|
||||||
|
|
||||||
if (PGTYPESnumeric_copy(num, numcopy) < 0)
|
if (PGTYPESnumeric_copy(num, numcopy) < 0)
|
||||||
{
|
{
|
||||||
PGTYPESnumeric_free(numcopy);
|
PGTYPESnumeric_free(numcopy);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dscale < 0)
|
||||||
|
dscale = num->dscale;
|
||||||
|
|
||||||
/* get_str_from_var may change its argument */
|
/* get_str_from_var may change its argument */
|
||||||
s = get_str_from_var(numcopy, dscale);
|
s = get_str_from_var(numcopy, dscale);
|
||||||
PGTYPESnumeric_free(numcopy);
|
PGTYPESnumeric_free(numcopy);
|
||||||
@ -1519,6 +1523,9 @@ numericvar_to_double(numeric *var, double *dp)
|
|||||||
char *endptr;
|
char *endptr;
|
||||||
numeric *varcopy = PGTYPESnumeric_new();
|
numeric *varcopy = PGTYPESnumeric_new();
|
||||||
|
|
||||||
|
if (varcopy == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (PGTYPESnumeric_copy(var, varcopy) < 0)
|
if (PGTYPESnumeric_copy(var, varcopy) < 0)
|
||||||
{
|
{
|
||||||
PGTYPESnumeric_free(varcopy);
|
PGTYPESnumeric_free(varcopy);
|
||||||
|
Loading…
Reference in New Issue
Block a user