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:26:41 +0000 (19:26 +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 f28bbc8550a8fcd087d8ad54d35b8362ee41e01b..32199631a353c4c9c017cde0bd06fbd38758638c 100644 (file)
@@ -1851,6 +1851,7 @@ pool_invalidate_query_cache(int num_table_oids, int *table_oid, bool unlinkp, in
                        return;
                }
        }
+       pfree(path);
 
        if (pool_is_shmem_cache())
        {
@@ -1882,6 +1883,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;
                }