]> granicus.if.org Git - postgresql/commitdiff
Fix assorted memory leaks.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 12 Jul 2015 20:25:51 +0000 (16:25 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 12 Jul 2015 20:26:18 +0000 (16:26 -0400)
Per Coverity (not that any of these are so non-obvious that they should not
have been caught before commit).  The extent of leakage is probably minor
to unnoticeable, but a leak is a leak.  Back-patch as necessary.

Michael Paquier

src/bin/pg_basebackup/streamutil.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_rewind/libpq_fetch.c
src/bin/scripts/vacuumdb.c

index a5cad350f8a498aed377da579851489de40732e8..91f919c34cd6f248cbaadb74eabdb8a413941b2c 100644 (file)
@@ -414,6 +414,7 @@ DropReplicationSlot(PGconn *conn, const char *slot_name)
                return false;
        }
 
+       destroyPQExpBuffer(query);
        PQclear(res);
        return true;
 }
index 32ac26f1db476cb34370ac82049d73f2575ef187..6664cee3b4cd8bf968f5588ca525ed2180025843 100644 (file)
@@ -6660,6 +6660,7 @@ getTransforms(Archive *fout, int *numTransforms)
                        appendPQExpBuffer(&namebuf, "%s %s",
                                                          typeInfo->dobj.name, lanname);
                transforminfo[i].dobj.name = namebuf.data;
+               free(lanname);
        }
 
        PQclear(res);
@@ -15731,6 +15732,7 @@ getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[]
                addObjectDependency(&contable->dataObj->dobj,
                                                        reftable->dataObj->dobj.dumpId);
        }
+       PQclear(res);
        destroyPQExpBuffer(query);
 }
 
index 05aa133cf36eaa527f0a331ba9e2ec0d145530c8..1979fbcb8a5f3d5b2fb6e275250aa0638a8883eb 100644 (file)
@@ -69,7 +69,7 @@ libpqConnect(const char *connstr)
        pg_free(str);
 
        /*
-        * Also check that full_page_writes is enabled. We can get torn pages if
+        * Also check that full_page_writes is enabled.  We can get torn pages if
         * a page is modified while we read it with pg_read_binary_file(), and we
         * rely on full page images to fix them.
         */
@@ -81,6 +81,7 @@ libpqConnect(const char *connstr)
 
 /*
  * Runs a query that returns a single value.
+ * The result should be pg_free'd after use.
  */
 static char *
 run_simple_query(const char *sql)
@@ -123,6 +124,8 @@ libpqGetCurrentXlogInsertLocation(void)
 
        result = ((uint64) hi) << 32 | lo;
 
+       pg_free(val);
+
        return result;
 }
 
@@ -201,6 +204,7 @@ libpqProcessFileList(void)
 
                process_source_file(path, type, filesize, link_target);
        }
+       PQclear(res);
 }
 
 /*----
@@ -296,7 +300,7 @@ receiveFileChunks(const char *sql)
                if (PQgetisnull(res, 0, 2))
                {
                        pg_log(PG_DEBUG,
-                                  "received NULL chunk for file \"%s\", file has been deleted\n",
+                         "received NULL chunk for file \"%s\", file has been deleted\n",
                                   filename);
                        pg_free(filename);
                        PQclear(res);
index ca6d00368325f6b9a27c21ecf00d9e022f9f4cb0..7e72db1edf7f287f8c8cf1c1a8c931c0bafc29a8 100644 (file)
@@ -393,9 +393,9 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
                for (i = 0; i < ntups; i++)
                {
                        appendPQExpBufferStr(&buf,
-                                                         fmtQualifiedId(PQserverVersion(conn),
-                                                                                        PQgetvalue(res, i, 1),
-                                                                                        PQgetvalue(res, i, 0)));
+                                                                fmtQualifiedId(PQserverVersion(conn),
+                                                                                               PQgetvalue(res, i, 1),
+                                                                                               PQgetvalue(res, i, 0)));
 
                        simple_string_list_append(&dbtables, buf.data);
                        resetPQExpBuffer(&buf);
@@ -412,6 +412,7 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
                        concurrentCons = ntups;
                if (concurrentCons <= 1)
                        parallel = false;
+               PQclear(res);
        }
 
        /*