On 10.10.2021 20:12, Peter Eisentraut wrote:
On 04.10.21 19:09, Sergey Shinderuk wrote:
I wonder what is the proper fix.  Just drop pfree() altogether or add
pstrdup() instead?  I see that makeMultirangeTypeName() doesn't bother
freeing its buf.

I think removing the pfree()s is a correct fix.


Thanks, here is a patch.


--
Sergey Shinderuk                https://postgrespro.com/
From 6c548f07d2a254da46cd0b6f6e99b7ed24a6b811 Mon Sep 17 00:00:00 2001
From: Sergey Shinderuk <s.shinde...@postgrespro.ru>
Date: Tue, 12 Oct 2021 07:57:42 +0300
Subject: [PATCH] Fix premature pfree() of multirange_type_name in
 DefineRange()

If the mutlirange_type_name parameter is given in the query, this would
erroneously pfree() the string in the parse tree.  Oversight in 6df7a9698bb0.
---
 src/backend/commands/typecmds.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index b290629a450..9ab40341793 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -1707,7 +1707,6 @@ DefineRange(ParseState *pstate, CreateRangeStmt *stmt)
        /* Create cast from the range type to its multirange type */
        CastCreate(typoid, multirangeOid, castFuncOid, 'e', 'f', 
DEPENDENCY_INTERNAL);
 
-       pfree(multirangeTypeName);
        pfree(multirangeArrayName);
 
        return address;
-- 
2.24.3 (Apple Git-128)

Reply via email to