Re: Plug minor memleak in pg_dump

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, bharath(dot)rupireddyforpostgres(at)gmail(dot)com, gkokolatos(at)pm(dot)me
Subject: Re: Plug minor memleak in pg_dump
Date: 2022-02-10 02:16:44
Message-ID: YgR1jEO7QLkim/Ee@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 09, 2022 at 02:48:35PM -0300, Ranier Vilela wrote:
> IMO I think that still have troubles here.
>
> ReadStr can return NULL, so the fix can crash.

- sscanf(tmp, "%u", &te->catalogId.tableoid);
- free(tmp);
+ if (tmp)
+ {
+ sscanf(tmp, "%u", &te->catalogId.tableoid);
+ free(tmp);
+ }
+ else
+ te->catalogId.tableoid = InvalidOid;

This patch makes things worse, doesn't it? Doesn't this localized
change mean that we expose ourselves more into *ignoring* TOC entries
if we mess up with this code in the future? That sounds particularly
sensible if you have a couple of bytes corrupted in a dump.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-02-10 02:22:05 Logging in LockBufferForCleanup()
Previous Message Amit Kapila 2022-02-10 02:14:22 Re: [BUG]Update Toast data failure in logical replication