Fixed memory leak bugs found by Martijn Oosterhout.
authorMichael Meskes <meskes@postgresql.org>
Mon, 24 Apr 2006 09:45:57 +0000 (09:45 +0000)
committerMichael Meskes <meskes@postgresql.org>
Mon, 24 Apr 2006 09:45:57 +0000 (09:45 +0000)
src/interfaces/ecpg/compatlib/informix.c
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/pgtypeslib/numeric.c

index 8acfc1ecf0784829c46a1a0dce75001c715265e7..f9af0247653b41f68cba5e28fdc2bb141a6ce66d 100644 (file)
@@ -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
index f5c0e214e7596f7ab4306784c1bc12a28a36f6db..10aea3ea92b72c654e540730f35980b37deb5d0e 100644 (file)
@@ -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);
index a59a7478d80e933d1e14bc8b2de7efbd6bdfd189..96bc356b971335ad95d8a093b6c50b888b6be86c 100644 (file)
@@ -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);
 }