mirror of
https://github.com/allankoechke/soci.git
synced 2026-11-30 10:58:24 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user