]> granicus.if.org Git - postgresql/commitdiff
Fix copy-pasto in freeing memory on error in vacuumlo.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 7 Jun 2019 09:42:27 +0000 (12:42 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 7 Jun 2019 09:42:27 +0000 (12:42 +0300)
It's harmless to call PQfreemem() with a NULL argument, so the only
consequence was that if allocating 'schema' failed, but allocating 'table'
or 'field' succeeded, we would leak a bit of memory. That's highly
unlikely to happen, so this is just academical, but let's get it right.

Per bug #15838 from Timur Birsh. Backpatch back to 9.5, where the
PQfreemem() calls were introduced.

Discussion: https://www.postgresql.org/message-id/15838-3221652c72c5e69d@postgresql.org

contrib/vacuumlo/vacuumlo.c

index ac3ff60e8149316aa7bef44a9a55a433dd9ec8df..73c06a043ed24e2e98956dcf00b43af52c55ca96 100644 (file)
@@ -243,9 +243,9 @@ vacuumlo(const char *database, const struct _param *param)
                        PQfinish(conn);
                        if (schema != NULL)
                                PQfreemem(schema);
-                       if (schema != NULL)
+                       if (table != NULL)
                                PQfreemem(table);
-                       if (schema != NULL)
+                       if (field != NULL)
                                PQfreemem(field);
                        return -1;
                }