commit 1094439c2b341030c39e8f25c7befcbf538d9af4
Author: Thibaut Cuvelier <tcuvel...@lyx.org>
Date:   Sat Feb 8 01:23:38 2025 +0100

    MathML: fix a crash in InsetMathMacro due to MacroData::mathml_type 
returning the address of a local object.
---
 src/mathed/InsetMathMacro.cpp | 2 +-
 src/mathed/MacroTable.cpp     | 5 ++---
 src/mathed/MacroTable.h       | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index 75520a7566..5513542365 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -1318,7 +1318,7 @@ void InsetMathMacro::mathmlize(MathMLStream & ms) const
        if (d->macro_) {
                docstring const xmlname = d->macro_->xmlname();
                if (!xmlname.empty()) {
-                       char const * type = d->macro_->MathMLtype();
+                       const std::string type = d->macro_->mathml_type();
                        ms << MTagInline(type) << xmlname << ETagInline(type);
                        return;
                }
diff --git a/src/mathed/MacroTable.cpp b/src/mathed/MacroTable.cpp
index d540a50a62..56f36a4595 100644
--- a/src/mathed/MacroTable.cpp
+++ b/src/mathed/MacroTable.cpp
@@ -129,10 +129,9 @@ docstring const MacroData::xmlname() const
 }
 
 
-char const * MacroData::MathMLtype() const
+std::string MacroData::mathml_type() const
 {
-       // TODO: when LyX requires C++17, move to string_view.
-       return sym_ ? sym_->mathml_type().c_str() : nullptr;
+       return sym_ ? sym_->mathml_type() : "";
 }
 
 
diff --git a/src/mathed/MacroTable.h b/src/mathed/MacroTable.h
index 6c17d63470..0c905d6c3c 100644
--- a/src/mathed/MacroTable.h
+++ b/src/mathed/MacroTable.h
@@ -65,7 +65,7 @@ public:
        ///
        docstring const xmlname() const;
        ///
-       char const * MathMLtype() const;
+       std::string mathml_type() const;
        ///
        latexkeys const * symbol() const { return sym_; }
        ///
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to