diff options
author | Michael Meskes <meskes@postgresql.org> | 2013-09-08 12:59:43 +0200 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2013-09-08 13:03:31 +0200 |
commit | 9c68834bfc2ab6e782f56ee3dc7b4949857b8729 (patch) | |
tree | 3f9950ecf58b27fb8ca75848bc9ba9beff4301c6 /src | |
parent | 579dae5bc0b87dfa53d0caa0ac57f0f5e739544f (diff) | |
download | postgresql-9c68834bfc2ab6e782f56ee3dc7b4949857b8729.tar.gz postgresql-9c68834bfc2ab6e782f56ee3dc7b4949857b8729.zip |
Return error if allocation of new element was not possible.
Found by Coverity.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/ecpg/pgtypeslib/numeric.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c index c56dda026ac..9ae975ecde0 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); @@ -1519,6 +1523,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); |