Skip to content

Commit bd171b3

Browse files
leopan3Lyu Pan
andauthored
pfree char* returned by TextDatumGetCString in is_pgtle_defined_c_func. (#222)
Although this is unlikely to cause a memory leak, still be consevative and free the memory. Co-authored-by: Lyu Pan <lyup@amazon.com>
1 parent 7c06d9c commit bd171b3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/tleextension.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5079,6 +5079,7 @@ is_pgtle_defined_c_func(Oid funcid, bool *is_operator_func)
50795079
char *prosrcstring;
50805080
bool isnull;
50815081
int nargs;
5082+
bool result;
50825083

50835084
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
50845085
if (!HeapTupleIsValid(tuple))
@@ -5106,9 +5107,11 @@ is_pgtle_defined_c_func(Oid funcid, bool *is_operator_func)
51065107
else
51075108
*is_operator_func = false;
51085109

5109-
return *is_operator_func ||
5110-
strncmp(prosrcstring, TLE_BASE_TYPE_IN, sizeof(TLE_BASE_TYPE_IN)) == 0 ||
5111-
strncmp(prosrcstring, TLE_BASE_TYPE_OUT, sizeof(TLE_BASE_TYPE_OUT)) == 0;
5110+
result = *is_operator_func ||
5111+
strncmp(prosrcstring, TLE_BASE_TYPE_IN, sizeof(TLE_BASE_TYPE_IN)) == 0 ||
5112+
strncmp(prosrcstring, TLE_BASE_TYPE_OUT, sizeof(TLE_BASE_TYPE_OUT)) == 0;
5113+
pfree(prosrcstring);
5114+
return result;
51125115
}
51135116

51145117
/*

0 commit comments

Comments
 (0)