From e93aba2bae8e76d1b1d2d9493742aa93c2b1b27b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 8 Oct 2023 16:02:30 +0100 Subject: Use unique_ptr for handling unescaped bytea column buffer --- libpqpp/pq-column.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libpqpp/pq-column.h') diff --git a/libpqpp/pq-column.h b/libpqpp/pq-column.h index f86958e..d3400bf 100644 --- a/libpqpp/pq-column.h +++ b/libpqpp/pq-column.h @@ -11,7 +11,6 @@ namespace PQ { class Column : public DB::Column { public: Column(const SelectBase *, unsigned int field); - ~Column() override; [[nodiscard]] bool isNull() const override; void apply(DB::HandleField &) const override; @@ -31,8 +30,18 @@ namespace PQ { const SelectBase * sc; const Oid oid; + // Buffer for PQunescapeBytea - mutable unsigned char * buf; + struct pq_deleter { + void + operator()(unsigned char * p) + { + PQfreemem(p); + } + }; + + using BufPtr = std::unique_ptr; + mutable BufPtr buf; }; } -- cgit v1.2.3