Fix resource leaks in pool_memqcache.c.
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 10 Sep 2024 10:20:03 +0000 (19:20 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 10 Sep 2024 10:20:03 +0000 (19:20 +0900)
6fdba5c33

These leaks were brought in by commit 6fdba5c33 " Use psprintf()
instead of snprintf()."  Since the commit was backpatched through 4.1,
this needs to be backpatched through 4.1 too.

Per Coverity (CID 1559736).
Backpatch-through: 4.1.

src/query_cache/pool_memqcache.c

index 84be8a26778fc8e341fbcfa2abd0a9cde81f5322..58e5e971441c77c95ab7440c8d94d2f0f1b6d669 100644 (file)
@@ -1855,6 +1855,7 @@ pool_invalidate_query_cache(int num_table_oids, int *table_oid, bool unlinkp, in
                        return;
                }
        }
+       pfree(path);
 
        if (pool_is_shmem_cache())
        {
@@ -1886,6 +1887,7 @@ pool_invalidate_query_cache(int num_table_oids, int *table_oid, bool unlinkp, in
                        ereport(DEBUG1,
                                        (errmsg("memcache invalidating query cache"),
                                         errdetail("failed to open \"%s\". reason:\"%m\"", path)));
+                       pfree(path);
                        continue;
                }