From fda56db0d95b4369f653d5bb89b1daf3c932d81c Mon Sep 17 00:00:00 2001 From: Stefan van Kessel Date: Thu, 24 Aug 2023 22:07:03 +0200 Subject: [PATCH] Delete soci::use for rvalues to prevent accidental stack-use-after-scope --- include/soci/use.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/soci/use.h b/include/soci/use.h index cf8c32a9e..9d0531020 100644 --- a/include/soci/use.h +++ b/include/soci/use.h @@ -46,6 +46,13 @@ struct use_container } // namespace details +// soci::use is deleted for rvalues because it will likely lead to subtle stack-use-after-scope bugs. +template +details::use_container use(T &&t, const std::string &name = std::string()) = delete; + +template +details::use_container use(T &&t, indicator & ind, std::string const &name = std::string()) = delete; + template details::use_container use(T &t, const std::string &name = std::string()) { return details::use_container(t, name); }