diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-10-09 00:44:46 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-10-09 00:44:46 +0100 |
commit | be8cfdfbc0a65ce93269281418b3ab41082a6994 (patch) | |
tree | 9b94d092307d88054eadfb88e39a17fb1a022a8a /libpqpp/pq-column.h | |
parent | Explicit instantiation of checkResult (diff) | |
download | libdbpp-postgresql-be8cfdfbc0a65ce93269281418b3ab41082a6994.tar.bz2 libdbpp-postgresql-be8cfdfbc0a65ce93269281418b3ab41082a6994.tar.xz libdbpp-postgresql-be8cfdfbc0a65ce93269281418b3ab41082a6994.zip |
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.
Diffstat (limited to 'libpqpp/pq-column.h')
-rw-r--r-- | libpqpp/pq-column.h | 10 |
1 files changed, 8 insertions, 2 deletions
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<unsigned char, pq_deleter<PQfreemem>>; - mutable BufPtr buf; + struct Buffer { + using BufPtr = std::unique_ptr<unsigned char, pq_deleter<PQfreemem>>; + size_t row {}; + size_t length {}; + BufPtr data; + }; + + mutable Buffer buffer; }; } |