gnucash stable: Bug 798812 - crashes after I open a customer report and select…

John Ralls jralls at code.gnucash.org
Sat Apr 15 16:32:49 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/f4f481fe (commit)
	from  https://github.com/Gnucash/gnucash/commit/96c8cb73 (commit)



commit f4f481fe38330fc18b7066285cf72ec546574e9f
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Apr 15 13:21:47 2023 -0700

    Bug 798812 - crashes after I open a customer report and select…
    
    Edit/Report Options
    
    As a result of auto instead of auto& in a std::visit call which
    resulted in a temporary option whose GncOwner* was destroyed before
    we could use it.

diff --git a/libgnucash/engine/gnc-option.cpp b/libgnucash/engine/gnc-option.cpp
index 81ce571b48..f43fd778d3 100644
--- a/libgnucash/engine/gnc-option.cpp
+++ b/libgnucash/engine/gnc-option.cpp
@@ -47,7 +47,7 @@ template <typename ValueType> ValueType
 GncOption::get_value() const
 {
     return std::visit(
-        [](const auto option)->ValueType {
+        [](const auto& option)->ValueType {
             if constexpr (is_same_decayed_v<decltype(option.get_value()),
                           ValueType>)
                 return option.get_value();
@@ -80,7 +80,7 @@ template <typename ValueType> ValueType
 GncOption::get_default_value() const
 {
     return std::visit(
-        [](const auto option)->ValueType {
+        [](const auto& option)->ValueType {
             if constexpr (is_same_decayed_v<decltype(option.get_value()),
                           ValueType>)
                 return option.get_default_value();



Summary of changes:
 libgnucash/engine/gnc-option.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



More information about the gnucash-changes mailing list