1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-05 23:56:58 +03:00

Fixed memory leak bugs found by Martijn Oosterhout.

This commit is contained in:
Michael Meskes 2006-04-24 09:45:44 +00:00
parent 499ec8c7e4
commit e37c0d2eb8
3 changed files with 10 additions and 15 deletions

View File

@ -164,15 +164,15 @@ ecpg_strndup(const char *str, size_t len)
int int
deccvasc(char *cp, int len, decimal *np) deccvasc(char *cp, int len, decimal *np)
{ {
char *str = ecpg_strndup(cp, len); /* decimal_in always converts char *str;
* the complete string */ int ret = 0;
int ret = 0; numeric *result;
numeric *result;
rsetnull(CDECIMALTYPE, (char *) np); rsetnull(CDECIMALTYPE, (char *) np);
if (risnull(CSTRINGTYPE, cp)) if (risnull(CSTRINGTYPE, cp))
return 0; return 0;
str = ecpg_strndup(cp, len); /* decimal_in always converts the complete string */
if (!str) if (!str)
ret = ECPG_INFORMIX_NUM_UNDERFLOW; ret = ECPG_INFORMIX_NUM_UNDERFLOW;
else else

View File

@ -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. * 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) 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) if (var->type == ECPGt_numeric)
PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval); PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);

View File

@ -362,24 +362,19 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
numeric *value = (numeric *) pgtypes_alloc(sizeof(numeric)); numeric *value = (numeric *) pgtypes_alloc(sizeof(numeric));
int ret; int ret;
#if 0
long typmod = -1;
#endif
char *realptr; char *realptr;
char **ptr = (endptr != NULL) ? endptr : &realptr; char **ptr = (endptr != NULL) ? endptr : &realptr;
if (!value) if (!value)
return (NULL); return (NULL);
ret = set_var_from_str(str, ptr, value); ret = set_var_from_str(str, ptr, value);
if (ret) if (ret)
{
free(value);
return (NULL); return (NULL);
}
#if 0
ret = apply_typmod(value, typmod);
if (ret)
return (NULL);
#endif
return (value); return (value);
} }