aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2006-04-24 09:45:44 +0000
committerMichael Meskes <meskes@postgresql.org>2006-04-24 09:45:44 +0000
commite37c0d2eb84d96ef4decc64504c93c7f114e9ac2 (patch)
tree81225be1d46f4e73c5ce45fa49058bd8d4887379 /src
parent499ec8c7e48b271e313d4a594074e702139f3721 (diff)
downloadpostgresql-e37c0d2eb84d96ef4decc64504c93c7f114e9ac2.tar.gz
postgresql-e37c0d2eb84d96ef4decc64504c93c7f114e9ac2.zip
Fixed memory leak bugs found by Martijn Oosterhout.
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/ecpg/compatlib/informix.c8
-rw-r--r--src/interfaces/ecpg/ecpglib/execute.c4
-rw-r--r--src/interfaces/ecpg/pgtypeslib/numeric.c13
3 files changed, 10 insertions, 15 deletions
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c
index 0cb45100429..b56929441cc 100644
--- a/src/interfaces/ecpg/compatlib/informix.c
+++ b/src/interfaces/ecpg/compatlib/informix.c
@@ -164,15 +164,15 @@ ecpg_strndup(const char *str, size_t len)
int
deccvasc(char *cp, int len, decimal *np)
{
- char *str = ecpg_strndup(cp, len); /* decimal_in always converts
- * the complete string */
- int ret = 0;
- numeric *result;
+ char *str;
+ int ret = 0;
+ numeric *result;
rsetnull(CDECIMALTYPE, (char *) np);
if (risnull(CSTRINGTYPE, cp))
return 0;
+ str = ecpg_strndup(cp, len); /* decimal_in always converts the complete string */
if (!str)
ret = ECPG_INFORMIX_NUM_UNDERFLOW;
else
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 870c9d2cc3c..9da8c2424e9 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.1 2005/11/30 12:50:37 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.2 2006/04/24 09:45:44 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@@ -860,7 +860,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
if (var->arrsize > 1)
{
- for (element = 0; element < var->arrsize; element++)
+ for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new())
{
if (var->type == ECPGt_numeric)
PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c
index 8ba0a093ecb..4ecfea1248a 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -362,24 +362,19 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
numeric *value = (numeric *) pgtypes_alloc(sizeof(numeric));
int ret;
-#if 0
- long typmod = -1;
-#endif
char *realptr;
char **ptr = (endptr != NULL) ? endptr : &realptr;
- if (!value)
+ if (!value)
return (NULL);
ret = set_var_from_str(str, ptr, value);
if (ret)
+ {
+ free(value);
return (NULL);
+ }
-#if 0
- ret = apply_typmod(value, typmod);
- if (ret)
- return (NULL);
-#endif
return (value);
}