[PATCH v1] fix potential memory leak in untransformRelOptions - Mailing list pgsql-hackers

From Junwang Zhao
Subject [PATCH v1] fix potential memory leak in untransformRelOptions
Date
Msg-id CAEG8a3Lz7M7tZ-7KR7243X+xHPiJVTm_9eZZvP5rfkH1bCWAJw@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH v1] fix potential memory leak in untransformRelOptions
Re: [PATCH v1] fix potential memory leak in untransformRelOptions
List pgsql-hackers
*TextDatumGetCString* calls palloc to alloc memory for the option
text datum, in some cases the the memory is allocated in
*TopTransactionContext*, this may cause memory leak for a long
running backend.
---
 src/backend/access/common/reloptions.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/backend/access/common/reloptions.c
b/src/backend/access/common/reloptions.c
index 609329bb21..6076677aef 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -1360,6 +1360,7 @@ untransformRelOptions(Datum options)
  val = (Node *) makeString(pstrdup(p));
  }
  result = lappend(result, makeDefElem(pstrdup(s), val, -1));
+ pfree(s);
  }

  return result;
-- 
2.33.0

-- 
Regards
Junwang Zhao

Attachment

pgsql-hackers by date:

Previous
From: Junwang Zhao
Date:
Subject: use NoLock instead of the magic number 0
Next
From: Dave Page
Date:
Subject: Re: Tracking last scan time