Fixed propagation of NULL indicators in the soci::values::set() function

Originally, the indicator passed by the user was copied into a stored-for-later
variable. This value could have been overwritten during conversion of the bound
parameter to its base type.

Signed-off-by: Innokentiy Alaytsev <alaitsev@gmail.com>
This commit is contained in:
Innokentiy Alaytsev
2026-03-16 16:12:02 +04:00
parent 56311049a2
commit b5603b93d1

View File

@@ -165,8 +165,17 @@ public:
indicator * pind = new indicator(indic);
indicators_.push_back(pind);
// If a NULL indicator was passes by the user, we must preserve it,
// even if conversion to the base type was successful.
indicator conv_ind = i_ok;
base_type baseValue{};
type_conversion<T>::to_base(value, baseValue, *pind);
type_conversion<T>::to_base(value, baseValue, conv_ind);
if (indic != i_null)
{
*pind = conv_ind;
}
details::copy_holder<base_type> * pcopy =
new details::copy_holder<base_type>(baseValue);
@@ -196,8 +205,18 @@ public:
indicators_.push_back(pind);
typedef typename type_conversion<T>::base_type base_type;
// If a NULL indicator was passes by the user, we must preserve it,
// even if conversion to the base type was successful.
indicator conv_ind = i_ok;
base_type baseValue;
type_conversion<T>::to_base(value, baseValue, *pind);
type_conversion<T>::to_base(value, baseValue, conv_ind);
if (indic != i_null)
{
*pind = conv_ind;
}
details::copy_holder<base_type> * pcopy =
new details::copy_holder<base_type>(baseValue);