From be8cfdfbc0a65ce93269281418b3ab41082a6994 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 9 Oct 2023 00:44:46 +0100 Subject: Avoid repeated calls to PQunescapeBytea Fixes issue where accessing the blob value of a column multiple times would free previously unescaped buffers resulting in dangling pointers. --- libpqpp/pq-column.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libpqpp/pq-column.h') diff --git a/libpqpp/pq-column.h b/libpqpp/pq-column.h index fa4a78a..4ef102d 100644 --- a/libpqpp/pq-column.h +++ b/libpqpp/pq-column.h @@ -24,8 +24,14 @@ namespace PQ { const Oid oid; // Buffer for PQunescapeBytea - using BufPtr = std::unique_ptr>; - mutable BufPtr buf; + struct Buffer { + using BufPtr = std::unique_ptr>; + size_t row {}; + size_t length {}; + BufPtr data; + }; + + mutable Buffer buffer; }; } -- cgit v1.2.3