From 0ba632afd1ac39797b7a78b0cbcac695c9da6a34 Mon Sep 17 00:00:00 2001 From: eelke Date: Wed, 19 Sep 2018 08:45:01 +0200 Subject: [PATCH] The getAsArray variation that uses a default value for NULL elements crashed when the array value itself was NULL. Choosen to return without error adding zero elements to the list. If you really need strict NULL handling do this using the other functions possibly checking for null before hand to choose other code path. --- pgsql/Pgsql_Value.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pgsql/Pgsql_Value.h b/pgsql/Pgsql_Value.h index b27f7ca..31a7e61 100644 --- a/pgsql/Pgsql_Value.h +++ b/pgsql/Pgsql_Value.h @@ -48,7 +48,7 @@ namespace Pgsql { { if (m_val == nullptr) { if (nullhandling == NullHandling::Throw) - throw std::runtime_error("Unexpected NULL value in array"); + throw std::runtime_error("Unexpected NULL value for array"); } else { using value_type = E; @@ -77,6 +77,8 @@ namespace Pgsql { template void getAsArray(I insert_iter, const E &value_for_nulls) const { + if (m_val == nullptr) return; + using value_type = E; ArrayParser parser(m_val); for (;;) {