diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c b/contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c index ac4135901b..8cc5f7dab2 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c @@ -1069,7 +1069,8 @@ TdsTypeNumericToDatum(StringInfo buf, int scale) Numeric res; int len, sign; - char *decString; + char *decString, + *decStringOrig; int temp1, temp2; uint128 num = 0; @@ -1088,6 +1089,7 @@ TdsTypeNumericToDatum(StringInfo buf, int scale) } decString = (char *) palloc0(sizeof(char) * 40); + decStringOrig = decString; if (num != 0) Integer2String(num, decString); @@ -1118,8 +1120,10 @@ TdsTypeNumericToDatum(StringInfo buf, int scale) * index during shifting the scale part of the string. */ decString = psprintf("-%s%s.", zeros, tempString + 1); + decStringOrig = decString; len = strlen(decString) - 1; pfree(tempString); + pfree(zeros); } if (num != 0) { @@ -1146,6 +1150,7 @@ TdsTypeNumericToDatum(StringInfo buf, int scale) decString++; res = TdsSetVarFromStrWrapper(decString); + pfree(decStringOrig); PG_RETURN_NUMERIC(res); }