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

index 973d7a8547d4efc3e3633e08f878e7f4843af2d6..538aa3dc47719ddf30727bd7aa7db5eb6da55464 100644 (file)
@@ -161,8 +161,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;
 
@@ -170,6 +169,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 0d1b8edefb63a9e392ba705c41e64dd06ac68fdd..49d10a9d36376a823a735d37cc6bcf2f4cb8df8f 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.26.2.5 2005/06/02 12:50:30 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.26.2.6 2006/04/24 09:46:32 meskes Exp $ */
 
 /*
  * The aim is to get a simpler inteface to the database routines.
@@ -848,7 +848,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
 
                    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 b06b8d14e5629d56f375b4d2bedf50e4f701cf80..0742f59851f45495b8849d094315c3d0f5f3a0e1 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);
 }