From 9145a3a4ee6b723881ad41568f880e862ffecb7c Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 6 Mar 2017 09:14:51 +0100 Subject: [PATCH] More defensive string construction in result set. --- include/sqlpp11/data_types/text/result_field.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/sqlpp11/data_types/text/result_field.h b/include/sqlpp11/data_types/text/result_field.h index 0c0f0d0b..7fb0883d 100644 --- a/include/sqlpp11/data_types/text/result_field.h +++ b/include/sqlpp11/data_types/text/result_field.h @@ -46,7 +46,10 @@ namespace sqlpp const char* text{nullptr}; size_t len{}; target._bind_text_result(index, &text, &len); - this->_value = {text, len}; + if (text) + this->_value = {text, len}; + else + this->value = {}; this->_is_null = (text == nullptr); } @@ -56,7 +59,10 @@ namespace sqlpp const char* text{nullptr}; size_t len{}; target._post_bind_text_result(index, &text, &len); - this->_value = {text, len}; + if (text) + this->_value = {text, len}; + else + this->value = {}; this->_is_null = (text == nullptr); } };