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; }