summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meskes2013-09-08 10:59:43 +0000
committerMichael Meskes2013-09-08 11:15:04 +0000
commit1b7f5168c5ebf232366f455a792c9d269308c9ba (patch)
treed157f53d70a22248f2b6fcf732eef14f5ad7e45d
parent0caf5629699104b94854a5cbb203a37227b2d763 (diff)
Return error if allocation of new element was not possible.
Found by Coverity.
-rw-r--r--src/interfaces/ecpg/pgtypeslib/numeric.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c
index 93505eaab18..7ec252c4456 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -402,14 +402,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);
@@ -1493,6 +1497,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);