[odb-users] Persisting empty binary values error. Microsoft SQL
Server
Andrey Paraskevopulo
andrey.psv at gmail.com
Sat May 23 07:33:15 EDT 2015
I need to store empty binary values in the binary fields.
I’ve try to persist record with empty std::vector<char> (or unsigned char),
but this lead to program termination.
(no matter what was the mapping type – varbinary(max) or image).
After short investigation I think that I’ve found the error.
odb\mssql\traits.cxx
void default_value_traits<std::vector<char>, id_long_binary
>::param_callback(...){
...
*buffer = &v.front ();
Calling std::vector::front function on an empty container causes undefined
behavior.
Possible solution:
replace this string with:
*buffer = v.empty()?nullptr:&v.front ();
(for both char and unsigned char).
I am not sure about side effects, but persisting empty vectors is working.
odb version 2.4.0
Andrey Paraskevopulo
More information about the odb-users
mailing list