]> granicus.if.org Git - postgresql/commitdiff
libpq: Fix minor memory leaks
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 16 Mar 2012 18:30:19 +0000 (20:30 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 16 Mar 2012 18:35:00 +0000 (20:35 +0200)
When using connection info arrays with a conninfo string in the dbname
slot, some memory would be leaked if an error occurred while
processing the following array slots.

found by Coverity

src/interfaces/libpq/fe-connect.c

index eece99ab1d6e5c3f21bf96807f1895e408d7ef52..817d83b9cb4382565e663b92ea86e1dd4adb0c4d 100644 (file)
@@ -4303,6 +4303,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values,
        {
                printfPQExpBuffer(errorMessage,
                                                  libpq_gettext("out of memory\n"));
+               PQconninfoFree(str_options);
                return NULL;
        }
        memcpy(options, PQconninfoOptions, sizeof(PQconninfoOptions));
@@ -4330,6 +4331,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values,
                                                 libpq_gettext("invalid connection option \"%s\"\n"),
                                                                  pname);
                                PQconninfoFree(options);
+                               PQconninfoFree(str_options);
                                return NULL;
                        }
 
@@ -4374,6 +4376,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values,
                                        printfPQExpBuffer(errorMessage,
                                                                          libpq_gettext("out of memory\n"));
                                        PQconninfoFree(options);
+                                       PQconninfoFree(str_options);
                                        return NULL;
                                }
                        }