From 1a4e543da2ca9829bef48b64ea6780a58a50f361 Mon Sep 17 00:00:00 2001 From: totaj Date: Fri, 9 Sep 2022 15:53:19 +0800 Subject: [PATCH] Fix mem overflow. --- src/gausskernel/optimizer/commands/trigger.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gausskernel/optimizer/commands/trigger.cpp b/src/gausskernel/optimizer/commands/trigger.cpp index 1654f3d95..8377f6ffb 100644 --- a/src/gausskernel/optimizer/commands/trigger.cpp +++ b/src/gausskernel/optimizer/commands/trigger.cpp @@ -1591,13 +1591,12 @@ void RelationBuildTriggers(Relation relation) if (numtrigs >= maxtrigs) { maxtrigs *= 2; triggers = (Trigger*)repalloc(triggers, maxtrigs * sizeof(Trigger)); + if (DB_IS_CMPT(B_FORMAT)) { + tgNameInfos = (TriggerNameInfo *)repalloc(tgNameInfos, maxtrigs * sizeof(TriggerNameInfo)); + } } if (u_sess->attr.attr_sql.sql_compatibility == B_FORMAT) { - TriggerNameInfo* tgNameInfo = NULL; - tgNameInfo = &(tgNameInfos[numtrigs]); - if (numtrigs >= maxtrigs) { - tgNameInfos = (TriggerNameInfo*)repalloc(tgNameInfos, maxtrigs * sizeof(TriggerNameInfo)); - } + TriggerNameInfo *tgNameInfo = &(tgNameInfos[numtrigs]); char* trigname = DatumGetCString(DirectFunctionCall1(nameout, NameGetDatum(&pg_trigger->tgname))); char* tgordername = DatumGetCString(fastgetattr(htup, Anum_pg_trigger_tgordername, tgrel->rd_att, &isnull));