From 5668c19ca0dcc328e1a45b152f9d4d202767dac0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 10 Dec 2020 18:49:38 +0000 Subject: Add check that upload ctx is non-null --- libmysqlpp/my-connection.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libmysqlpp') diff --git a/libmysqlpp/my-connection.cpp b/libmysqlpp/my-connection.cpp index 6e4d1a1..30cef18 100644 --- a/libmysqlpp/my-connection.cpp +++ b/libmysqlpp/my-connection.cpp @@ -210,6 +210,9 @@ MySQL::Connection::beginBulkUpload(const char * table, const char * extra) void MySQL::Connection::endBulkUpload(const char * msg) { + if (!ctx) { + throw std::logic_error("No bulk upload in progress"); + } ctx->loadBuf = nullptr; ctx->loadBufLen = 0; ctx->bufOff = msg ? -1 : 0; @@ -228,6 +231,9 @@ MySQL::Connection::endBulkUpload(const char * msg) size_t MySQL::Connection::bulkUploadData(const char * data, size_t len) const { + if (!ctx) { + throw std::logic_error("No bulk upload in progress"); + } ctx->loadBuf = data; ctx->loadBufLen = len; ctx->bufOff = 0; -- cgit v1.2.3