Fix a resource leak (src/backend/utils/adt/rowtypes.c) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Fix a resource leak (src/backend/utils/adt/rowtypes.c)
Date
Msg-id CAEudQApNjhD49jjjPpu0ykG+qLVMQdMa_SBPn9yXhAPL0E4__Q@mail.gmail.com
Whole thread Raw
Responses Re: Fix a resource leak (src/backend/utils/adt/rowtypes.c)
List pgsql-hackers
Hi.

Per Coverity.

CID 1608916: (#1 of 1): Resource leak (RESOURCE_LEAK)
52. leaked_storage: Variable buf going out of scope leaks the storage buf.data points to. 

The function *record_in* has a new report about resource leak.
I think Coverity is right.
The normal path of the function frees the memory of several variables used.
Therefore the failure path should also free them.
A quick search on the web shows several occurrences of "malformed record literal", therefore failure is common in this function.

Although Coveriy reports the leak of only buf.data, the variables *values* and *nulls* should also be released.

While there, move the creation of stringdata, to ensure that in case of failure, the buf.data variable is released correctly.

Attached a path.

best regards,
Ranier Vilela

Attachment

pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: Logical Replication of sequences
Next
From: Michael Paquier
Date:
Subject: Re: Back-patch of: avoid multiple hard links to same WAL file after a crash