Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1a29217

Browse files
Free temporary memory when reading TOC
ReadStr returns allocated memory which the caller is responsible for freeing when done with the string. This commit ensures that memory is freed in one case which used ReadStr in a conditional. While the leak might not be too concerning, this makes the code consistent across all ReadStr callsites in ReadToc. Due to the lack of complaints of issues in production from this, no backpatch is performed at this point. Author: Bharath Rupireddy, Georgios Kokolatos Reviewed-by: Kyotaro Horiguchi Discussion: https://postgr.es/m/oZwKiUxFsVaetG2xOJp7Hwao8F1AKIdfFDQLNJrnwoaxmjyB-45r_aYmhgXHKLcMI3GT24m9L6HafSi2ns7WFxXe0mw2_tIJpD-Z3vb_eyI=@pm.me
1 parent cf29a11 commit 1a29217

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2494,6 +2494,7 @@ ReadToc(ArchiveHandle *AH)
24942494
int depIdx;
24952495
int depSize;
24962496
TocEntry *te;
2497+
bool is_supported;
24972498

24982499
AH->tocCount = ReadInt(AH);
24992500
AH->maxDumpId = 0;
@@ -2574,7 +2575,20 @@ ReadToc(ArchiveHandle *AH)
25742575
te->tableam = ReadStr(AH);
25752576

25762577
te->owner = ReadStr(AH);
2577-
if (AH->version < K_VERS_1_9 || strcmp(ReadStr(AH), "true") == 0)
2578+
is_supported = true;
2579+
if (AH->version < K_VERS_1_9)
2580+
is_supported = false;
2581+
else
2582+
{
2583+
tmp = ReadStr(AH);
2584+
2585+
if (strcmp(tmp, "true") == 0)
2586+
is_supported = false;
2587+
2588+
free(tmp);
2589+
}
2590+
2591+
if (!is_supported)
25782592
pg_log_warning("restoring tables WITH OIDS is not supported anymore");
25792593

25802594
/* Read TOC entry dependencies */

0 commit comments

Comments
 (0)