v1-0001-Plug-minor-leak-while-reading-Table-of-Contents.patch
text/x-patch
Filename: v1-0001-Plug-minor-leak-while-reading-Table-of-Contents.patch
Type: text/x-patch
Part: 0
Message:
Plug minor memleak in pg_dump
Patch
Format: format-patch
Series: patch v1-0001
Subject: Plug minor leak while reading Table of Contents
| File | + | − |
|---|---|---|
| src/bin/pg_dump/pg_backup_archiver.c | 8 | 1 |
From 9473d1106c2816550094f5dea939fc3c6a469f4d Mon Sep 17 00:00:00 2001
From: Georgios Kokolatos <gkokolatos@pm.me>
Date: Tue, 1 Feb 2022 13:08:48 +0000
Subject: [PATCH v1] Plug minor leak while reading Table of Contents
ReadStr() returns a malloc'ed pointer. Using it directly in a function
call results in a memleak. Rewrite to use a temporary buffer which is
then freed.
---
src/bin/pg_dump/pg_backup_archiver.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 49bf090..b2d7d21 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -2574,8 +2574,15 @@ ReadToc(ArchiveHandle *AH)
te->tableam = ReadStr(AH);
te->owner = ReadStr(AH);
- if (AH->version < K_VERS_1_9 || strcmp(ReadStr(AH), "true") == 0)
+ if (AH->version < K_VERS_1_9)
pg_log_warning("restoring tables WITH OIDS is not supported anymore");
+ else
+ {
+ tmp = ReadStr(AH);
+ if (strcmp(tmp, "true") == 0)
+ pg_log_warning("restoring tables WITH OIDS is not supported anymore");
+ pg_free(tmp);
+ }
/* Read TOC entry dependencies */
if (AH->version >= K_VERS_1_5)
--
2.34.1