From a0b20e561cf5b2fb16e76953f9714c1d53d2f33a Mon Sep 17 00:00:00 2001 From: Igor Gaponenko Date: Thu, 15 Jun 2023 00:50:52 -0700 Subject: [PATCH] Fixed a bug in the SQL library --- src/sql/SqlResults.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sql/SqlResults.cc b/src/sql/SqlResults.cc index baa6eccb27..c2cd8e8b0c 100644 --- a/src/sql/SqlResults.cc +++ b/src/sql/SqlResults.cc @@ -183,7 +183,12 @@ bool SqlResults::extractFirstValue(std::string& ret, SqlErrorObject& errObj) { if (!row) { return errObj.addErrMsg("Expecting one row, found no rows"); } - ret = (row[0]); + auto ptr = row[0]; + if (!ptr) { + freeResults(); + return errObj.addErrMsg("NULL returned by the query"); + } + ret = ptr; freeResults(); return true; }