Re: Plug minor memleak in pg_dump - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Plug minor memleak in pg_dump
Date
Msg-id YgR1jEO7QLkim/Ee@paquier.xyz
Whole thread Raw
In response to Re: Plug minor memleak in pg_dump  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: Plug minor memleak in pg_dump
List 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

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [BUG]Update Toast data failure in logical replication
Next
From: Andres Freund
Date:
Subject: Logging in LockBufferForCleanup()