diff options
author | Michael Meskes <meskes@postgresql.org> | 2006-04-24 09:45:57 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2006-04-24 09:45:57 +0000 |
commit | 46942e84d94bb25ef95cd32ac41c259e1825a47d (patch) | |
tree | 84fbe883205e197d1d2e9c2ee724c94aed076751 /src | |
parent | 8f7fce2fd6d94a3fd3dd2eb8a1a5983c57c7d1d2 (diff) | |
download | postgresql-46942e84d94bb25ef95cd32ac41c259e1825a47d.tar.gz postgresql-46942e84d94bb25ef95cd32ac41c259e1825a47d.zip |
Fixed memory leak bugs found by Martijn Oosterhout.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/ecpg/compatlib/informix.c | 5 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 4 | ||||
-rw-r--r-- | src/interfaces/ecpg/pgtypeslib/numeric.c | 13 |
3 files changed, 8 insertions, 14 deletions
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index 8acfc1ecf07..f9af0247653 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -164,9 +164,7 @@ 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 */ + char *str; int ret = 0; numeric *result; @@ -174,6 +172,7 @@ deccvasc(char *cp, int len, decimal *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 f5c0e214e75..10aea3ea92b 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.38.4.3 2005/11/30 12:51:06 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.38.4.4 2006/04/24 09:45:57 meskes Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -869,7 +869,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 a59a7478d80..96bc356b971 100644 --- a/src/interfaces/ecpg/pgtypeslib/numeric.c +++ b/src/interfaces/ecpg/pgtypeslib/numeric.c @@ -363,24 +363,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); } |