mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-28 01:21:49 +02:00
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
This commit is contained in:
parent
cf29a11ef6
commit
1a29217a00
@ -2494,6 +2494,7 @@ ReadToc(ArchiveHandle *AH)
|
|||||||
int depIdx;
|
int depIdx;
|
||||||
int depSize;
|
int depSize;
|
||||||
TocEntry *te;
|
TocEntry *te;
|
||||||
|
bool is_supported;
|
||||||
|
|
||||||
AH->tocCount = ReadInt(AH);
|
AH->tocCount = ReadInt(AH);
|
||||||
AH->maxDumpId = 0;
|
AH->maxDumpId = 0;
|
||||||
@ -2574,7 +2575,20 @@ ReadToc(ArchiveHandle *AH)
|
|||||||
te->tableam = ReadStr(AH);
|
te->tableam = ReadStr(AH);
|
||||||
|
|
||||||
te->owner = ReadStr(AH);
|
te->owner = ReadStr(AH);
|
||||||
if (AH->version < K_VERS_1_9 || strcmp(ReadStr(AH), "true") == 0)
|
is_supported = true;
|
||||||
|
if (AH->version < K_VERS_1_9)
|
||||||
|
is_supported = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp = ReadStr(AH);
|
||||||
|
|
||||||
|
if (strcmp(tmp, "true") == 0)
|
||||||
|
is_supported = false;
|
||||||
|
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_supported)
|
||||||
pg_log_warning("restoring tables WITH OIDS is not supported anymore");
|
pg_log_warning("restoring tables WITH OIDS is not supported anymore");
|
||||||
|
|
||||||
/* Read TOC entry dependencies */
|
/* Read TOC entry dependencies */
|
||||||
|
Loading…
Reference in New Issue
Block a user