Do not eat memory even in case of an out-of-memory error.
authorMichael Meskes <meskes@postgresql.org>
Sat, 1 Nov 2008 08:55:21 +0000 (08:55 +0000)
committerMichael Meskes <meskes@postgresql.org>
Sat, 1 Nov 2008 08:55:21 +0000 (08:55 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/compatlib/informix.c

index 928d412c953f3d5b90743ac3577ed4993d42ac63..3d8d6ab25f6e5da8c48465177aa72dadbeaa80aa 100644 (file)
@@ -2386,6 +2386,10 @@ Fri, 10 Oct 2008 14:03:05 +0200
 Tue, 14 Oct 2008 11:25:51 +0200
 
        - Fixed parameter parsing.
+
+Sat, 25 Oct 2008 16:34:28 +0200
+
+       - Free allocated memory even if the next alloc failed with ENOMEM.
        - Set pgtypes library version to 3.1.
        - Set compat library version to 3.1.
        - Set ecpg library version to 6.2.
index 9bbc9c085bb1973ce6d6b6839ffa4bb6d12c7e33..7d084cf56f2b6c171ea46c19ea8cadf2971320df 100644 (file)
@@ -755,10 +755,16 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
                                fmtchar = ' ';
 
        temp = (char *) malloc(fmt_len + 1);
+       if (!temp)
+       {
+               errno = ENOMEM;
+               return -1;
+       }
 
        /* put all info about the long in a struct */
-       if (!temp || initValue(lng_val) == -1)
+       if (initValue(lng_val) == -1)
        {
+               free(temp);
                errno = ENOMEM;
                return -1;
        }