aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2006-06-26 09:20:19 +0000
committerMichael Meskes <meskes@postgresql.org>2006-06-26 09:20:19 +0000
commit1bdea12e5c3296ed91b356fc11fe722f67bfc2c8 (patch)
tree7717f94eac67ddf9e04768e21e2a4516d68e08d6
parent1f9acaf21d35796b962446a69d12f87e0e673668 (diff)
downloadpostgresql-1bdea12e5c3296ed91b356fc11fe722f67bfc2c8.tar.gz
postgresql-1bdea12e5c3296ed91b356fc11fe722f67bfc2c8.zip
Added some more coverity report patches send in by Joachim Wieland <joe@mcknight.de>.
-rw-r--r--src/interfaces/ecpg/compatlib/informix.c1
-rw-r--r--src/interfaces/ecpg/ecpglib/execute.c20
2 files changed, 11 insertions, 10 deletions
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c
index 3cd8977521b..a92bca88c0c 100644
--- a/src/interfaces/ecpg/compatlib/informix.c
+++ b/src/interfaces/ecpg/compatlib/informix.c
@@ -415,6 +415,7 @@ dectoint(decimal *np, int *ip)
}
ret = PGTYPESnumeric_to_int(nres, ip);
+ PGTYPESnumeric_free(nres);
if (ret == PGTYPES_NUM_OVERFLOW)
ret = ECPG_INFORMIX_NUM_OVERFLOW;
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index e1cc60e88b6..f8d348d0a86 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.5 2006/06/25 09:59:18 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.6 2006/06/26 09:20:19 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@@ -870,16 +870,16 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
case ECPGt_numeric:
{
char *str = NULL;
- int slen;
+ int slen;
numeric *nval = PGTYPESnumeric_new();
- if (!nval)
- return false;
-
if (var->arrsize > 1)
{
for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new())
{
+ if (!nval)
+ return false;
+
if (var->type == ECPGt_numeric)
PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);
else
@@ -887,10 +887,10 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
slen = strlen(str);
+ PGTYPESnumeric_free(nval);
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [] "), lineno)))
{
- PGTYPESnumeric_free(nval);
ECPGfree(str);
return false;
}
@@ -901,24 +901,25 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ECPGfree(str);
- PGTYPESnumeric_free(nval);
}
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
}
else
{
+ if (!nval)
+ return false;
+
if (var->type == ECPGt_numeric)
PGTYPESnumeric_copy((numeric *) (var->value), nval);
else
PGTYPESnumeric_from_decimal((decimal *) (var->value), nval);
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
-
slen = strlen(str);
+ PGTYPESnumeric_free(nval);
if (!(mallocedval = ECPGalloc(slen + 1, lineno)))
{
- PGTYPESnumeric_free(nval);
free(str);
return false;
}
@@ -926,7 +927,6 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
strncpy(mallocedval, str, slen);
mallocedval[slen] = '\0';
ECPGfree(str);
- PGTYPESnumeric_free(nval);
}
*tobeinserted_p = mallocedval;