Skip to content

Commit

Permalink
pfree char* returned by TextDatumGetCString in is_pgtle_defined_c_fun…
Browse files Browse the repository at this point in the history
…c. (#222)

Although this is unlikely to cause a memory leak, still be consevative and free the memory.

Co-authored-by: Lyu Pan <[email protected]>
  • Loading branch information
lyupan and Lyu Pan authored Jul 24, 2023
1 parent 7c06d9c commit bd171b3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/tleextension.c
Original file line number Diff line number Diff line change
Expand Up @@ -5079,6 +5079,7 @@ is_pgtle_defined_c_func(Oid funcid, bool *is_operator_func)
char *prosrcstring;
bool isnull;
int nargs;
bool result;

tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tuple))
Expand Down Expand Up @@ -5106,9 +5107,11 @@ is_pgtle_defined_c_func(Oid funcid, bool *is_operator_func)
else
*is_operator_func = false;

return *is_operator_func ||
strncmp(prosrcstring, TLE_BASE_TYPE_IN, sizeof(TLE_BASE_TYPE_IN)) == 0 ||
strncmp(prosrcstring, TLE_BASE_TYPE_OUT, sizeof(TLE_BASE_TYPE_OUT)) == 0;
result = *is_operator_func ||
strncmp(prosrcstring, TLE_BASE_TYPE_IN, sizeof(TLE_BASE_TYPE_IN)) == 0 ||
strncmp(prosrcstring, TLE_BASE_TYPE_OUT, sizeof(TLE_BASE_TYPE_OUT)) == 0;
pfree(prosrcstring);
return result;
}

/*
Expand Down

0 comments on commit bd171b3

Please sign in to comment.