postgres.git / summary / log / commit / refs
commit 994362a317ced987b6ea616b236c402d715ddcd5
Author: Michael Meskes <meskes@postgresql.org>
Date: Sun Sep 08 10:59:43 2013 +0000
First released in: 9.4.0, 8.4.18, 9.0.14, 9.1.10, 9.2.5, 9.3.1
Return error if allocation of new element was not possible.
Found by Coverity.
src/interfaces/ecpg/pgtypeslib/numeric.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c
index 7257c812542..55c5b45616e 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -430,14 +430,18 @@ PGTYPESnumeric_to_asc(numeric *num, int dscale)
numeric *numcopy = PGTYPESnumeric_new();
char *s;
- if (dscale < 0)
- dscale = num->dscale;
+ if (numcopy == NULL)
+ return NULL;
if (PGTYPESnumeric_copy(num, numcopy) < 0)
{
PGTYPESnumeric_free(numcopy);
return NULL;
}
+
+ if (dscale < 0)
+ dscale = num->dscale;
+
/* get_str_from_var may change its argument */
s = get_str_from_var(numcopy, dscale);
PGTYPESnumeric_free(numcopy);
@@ -1520,6 +1524,9 @@ numericvar_to_double(numeric *var, double *dp)
char *endptr;
numeric *varcopy = PGTYPESnumeric_new();
+ if (varcopy == NULL)
+ return -1;
+
if (PGTYPESnumeric_copy(var, varcopy) < 0)
{
PGTYPESnumeric_free(varcopy);
[parent: aef9d25aa3dc]