Skip to content

Commit

Permalink
Delete soci::use for rvalues to prevent accidental stack-use-after-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVK committed Aug 24, 2023
1 parent 924d990 commit fda56db
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/soci/use.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ struct use_container<T, no_indicator>

} // namespace details

// soci::use is deleted for rvalues because it will likely lead to subtle stack-use-after-scope bugs.
template <typename T>
details::use_container<T, details::no_indicator> use(T &&t, const std::string &name = std::string()) = delete;

template <typename T>
details::use_container<const T, indicator> use(T &&t, indicator & ind, std::string const &name = std::string()) = delete;

template <typename T>
details::use_container<T, details::no_indicator> use(T &t, const std::string &name = std::string())
{ return details::use_container<T, details::no_indicator>(t, name); }
Expand Down

0 comments on commit fda56db

Please sign in to comment.