Skip to content

Commit 7376390

Browse files
committed
Fix bogus size calculation in strlist_to_textarray().
It's making an array of Datum, not an array of text *. The mistake is harmless since those are currently the same size, but it's still wrong.
1 parent 335f3d0 commit 7376390

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/backend/catalog/objectaddress.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5051,7 +5051,7 @@ getRelationIdentity(StringInfo buffer, Oid relid, List **object)
50515051
}
50525052

50535053
/*
5054-
* Auxiliary function to return a TEXT array out of a list of C-strings.
5054+
* Auxiliary function to build a TEXT array out of a list of C-strings.
50555055
*/
50565056
ArrayType *
50575057
strlist_to_textarray(List *list)
@@ -5063,12 +5063,14 @@ strlist_to_textarray(List *list)
50635063
MemoryContext memcxt;
50645064
MemoryContext oldcxt;
50655065

5066+
/* Work in a temp context; easier than individually pfree'ing the Datums */
50665067
memcxt = AllocSetContextCreate(CurrentMemoryContext,
50675068
"strlist to array",
50685069
ALLOCSET_DEFAULT_SIZES);
50695070
oldcxt = MemoryContextSwitchTo(memcxt);
50705071

5071-
datums = palloc(sizeof(text *) * list_length(list));
5072+
datums = (Datum *) palloc(sizeof(Datum) * list_length(list));
5073+
50725074
foreach(cell, list)
50735075
{
50745076
char *name = lfirst(cell);
@@ -5080,6 +5082,7 @@ strlist_to_textarray(List *list)
50805082

50815083
arr = construct_array(datums, list_length(list),
50825084
TEXTOID, -1, false, 'i');
5085+
50835086
MemoryContextDelete(memcxt);
50845087

50855088
return arr;

0 commit comments

Comments
 (0)