From cb066d59f5394beb88ac5b92c8a6db51494c9799 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 21 Apr 2023 21:32:27 +0100 Subject: Don't use &vector.front() for vector which might be empty Instead just use .data() which safely returns something which might be nullptr, but that's fine. --- libpqpp/pq-modifycommand.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libpqpp/pq-modifycommand.cpp') diff --git a/libpqpp/pq-modifycommand.cpp b/libpqpp/pq-modifycommand.cpp index 38c10f6..b29fda7 100644 --- a/libpqpp/pq-modifycommand.cpp +++ b/libpqpp/pq-modifycommand.cpp @@ -15,8 +15,8 @@ PQ::ModifyCommand::ModifyCommand(Connection * conn, const std::string & sql, con unsigned int PQ::ModifyCommand::execute(bool anc) { - PGresult * res = PQexecPrepared(c->conn, prepare(), static_cast(values.size()), &values.front(), - &lengths.front(), &formats.front(), 0); + PGresult * res = PQexecPrepared( + c->conn, prepare(), static_cast(values.size()), values.data(), lengths.data(), formats.data(), 0); c->checkResult(res, PGRES_COMMAND_OK, PGRES_TUPLES_OK); auto rows = atoi(PQcmdTuples(res)); PQclear(res); -- cgit v1.2.3