Skip to content

Commit ad450a6

Browse files
committed
Make remapper->typmodmap alloc in remapper->mycontext.
remapper->typmodmap was alloc in MotionLayerMemCtxt, which will reset ExecutorEnd(). When transcation abort, DestroyTupleRemapper will try free pfree(remapper->typmodmap), this make free a wild pointer,core dump occurred.
1 parent 563b7ca commit ad450a6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/backend/cdb/motion/tupleremap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,12 @@ TRHandleTypeLists(TupleRemapper *remapper, List *typelist)
224224
ListCell *cell;
225225
int mapsize = remapper->typmodmapsize + list_length(typelist);
226226

227+
MemoryContext oldcontext = MemoryContextSwitchTo(remapper->mycontext);
227228
if (remapper->typmodmap)
228229
remapper->typmodmap = repalloc(remapper->typmodmap, mapsize * sizeof(int32));
229230
else
230231
remapper->typmodmap = palloc(mapsize * sizeof(int32));
232+
MemoryContextSwitchTo(oldcontext);
231233

232234
for (j = 0; j < list_length(typelist); j++)
233235
remapper->typmodmap[remapper->typmodmapsize + j] = -1;

0 commit comments

Comments
 (0)