Skip to content

Commit 54f93e0

Browse files
committed
fix(cloudsync_postgresql): only free quoted identifiers if they're different from the input
1 parent 971538b commit 54f93e0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/postgresql/cloudsync_postgresql.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,17 +2025,21 @@ static char * build_union_sql (void) {
20252025
CLOUDSYNC_RLS_RESTRICTED_VALUE_BYTEA
20262026
);
20272027

2028-
pfree((void*)quoted_base_ident);
2028+
// Only free quoted identifiers if they're different from the input
2029+
// (quote_identifier returns input pointer if no quoting needed)
2030+
if (quoted_base_ident != base) pfree((void*)quoted_base_ident);
20292031
pfree(joincond.data);
20302032
pfree(caseexpr.data);
2031-
2033+
20322034
pfree(base);
2033-
2035+
pfree(base_lit);
2036+
20342037
pfree(quoted_base);
2038+
pfree(nsp_lit);
20352039
pfree(nsp);
2036-
pfree((void *)quoted_nsp);
2040+
if (quoted_nsp != nsp) pfree((void *)quoted_nsp);
20372041
pfree(rel);
2038-
pfree((void *)quoted_rel);
2042+
if (quoted_rel != rel) pfree((void *)quoted_rel);
20392043
}
20402044
if (nsp_list) pfree(nsp_list);
20412045
if (rel_list) pfree(rel_list);

0 commit comments

Comments
 (0)