Skip to content

Commit d179b1c

Browse files
committed
Fixed memory allocations in PG BLOB functions
1 parent 3d98ea5 commit d179b1c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/postgresql/cloudsync_postgresql.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Datum pg_cloudsync_siteid (PG_FUNCTION_ARGS) {
130130
}
131131

132132
// Return as bytea (binary UUID)
133-
bytea *result = (bytea *)cloudsync_memory_alloc(VARHDRSZ + UUID_LEN);
133+
bytea *result = (bytea *)palloc(VARHDRSZ + UUID_LEN);
134134
SET_VARSIZE(result, VARHDRSZ + UUID_LEN);
135135
memcpy(VARDATA(result), siteid, UUID_LEN);
136136

@@ -146,7 +146,7 @@ Datum cloudsync_uuid (PG_FUNCTION_ARGS) {
146146
cloudsync_uuid_v7(uuid);
147147

148148
// Return as bytea
149-
bytea *result = (bytea *)cloudsync_memory_alloc(VARHDRSZ + UUID_LEN);
149+
bytea *result = (bytea *)palloc(VARHDRSZ + UUID_LEN);
150150
SET_VARSIZE(result, VARHDRSZ + UUID_LEN);
151151
memcpy(VARDATA(result), uuid, UUID_LEN);
152152

@@ -679,7 +679,7 @@ Datum cloudsync_payload_encode_finalfn (PG_FUNCTION_ARGS) {
679679
PG_RETURN_NULL();
680680
}
681681

682-
bytea *result = (bytea *)cloudsync_memory_alloc(VARHDRSZ + blob_size);
682+
bytea *result = (bytea *)palloc(VARHDRSZ + blob_size);
683683
SET_VARSIZE(result, VARHDRSZ + blob_size);
684684
memcpy(VARDATA(result), blob, blob_size);
685685

0 commit comments

Comments
 (0)